Comments can be used to ...
- explain Python code
- make code more readable
- prevent execution when testing code
Creating a Comment
-starts with "#"
- Create a Comment in VSCode, the easy way. On Windows, the shortcut is: CTRL + / On Mac, the shortcut is: Command + /*
Example
#This is a comment
print("Hello, World!")
Python will ignore string literals that are not assigned to a variable.
- add a multiline string (triple quotes) in your code and place your comment inside it.
"""
This is a comment
written in
more than just one line
"""
Top comments (0)