Why should I write comments in my code?


#1

Question

Is there a reason to comment code? If I’m writing it, I’m familiar with what it’s doing.

Answer

Writing helpful comments in your programs is an excellent habit! You may understand what you’re writing in the moment, but if you look at that same code six months from now, it may not be so clear, especially as your projects grow in size!

It’s a good idea to briefly explain your code anywhere you think it might help your future self, or other programmers who may read your code.


FAQ: Learn Python - Python Syntax - Comments