Comments

Not every bit of code you write has to do something. Python, as with many other programming languages, allow us to write comments - code written for developers that are not executed by the compiler or interpreter. In Python, comments begin with #.

# Comments are ignored by the interpreter
print('42') # You can have in-line comments as well, everything after # is ignored

Comments are useful for explaining code to a programmer. In this course you'll see many comments to guide you on how to follow a lesson or to give instructions for an exercise. That's now how comments are usually used in software developement. A good comment should explain why the code is doing what it's doing, now how. Good code should explain how it works, no comment can replace that.

Last updated