Python Comments
Comments are a way to document your Python script. There are several ways to use comments but the best advice we can give is to use them as much as possible! There are a few ways to make a comment in Python.
Individual Lines
You can start a line with a pound/hash (#) sign, or put one anywhere in a normal line of code.
#
this
is a comment
print
'Hello world'
#
this
is also a valid comment
Blocks of Lines
You can start and end a section of comments with a triple quote (''' or """)
''
'
This is a lot of text
that you want to show as multiple lines of
comments
Script written by Professor X.
Jan
5
,
1990
''
'
print
'Hello world'
Comment many lines with a keyboard shortcut
You can use the Ctrl-/ keyboard shortcut to comment several lines of code at once. Just highlight 1 or more lines of code and hold the Ctrl key and press /