Python, like almost all programming languages, lets you add comments to your program. Comments are text in your program that the Python interpreter ignores. Why would you want to add stuff that the computer ignores? Comments help other people understand how the program works. They also let you decipher your own code six months later!
To add a comment to your program, type # (a pound sign) and then type your comment.
You can type # either at the beginning of a line of code or after the code. If you write a comment that spans more than one line, use # at the beginning of each line.
The example below shows comments in action:
# These are lines from Monty Python's "Parrot Sketch"
live parrot = "'E's pinin' for the fjords!" # Michael Palin dead parrot = "Bereft of life, 'e rests in peace!" # John Cleese
Was this article helpful?