Every day we wake up, have a nice breakfast, head to the computer and there we sit, to write perfect code that does exactly what we want.
Then we wake up.
That would be ideal, right? But it was a dream.
As good as you can become, there’s no way you can write bug-free code. Code has bugs. By definition.
A bug is a problem that you did not see or anticipate when you set out to write the code.
A bug might be discovered only when you release your program to users, and that’s the worse situation.
A bug can be discovered by yourself when you test the program, and it might even happen when things - working perfectly previously - starts to break because you changed one line.
Those are called regression bugs.