1.2 - Comments

Comments are useful for explaining what code does. Comments are ignored when your code runs, so you can write anything you want in them. Comments start on a new line with a # symbol. Here's an example:

# This is a comment
print("Hello!")

Comments can be placed after a line of code. In this example, the comment explains what print does.

print("Hello!") # this prints "Hello!" to the screen

# print("Hello!")

A comment has been added before the print on the last line. Notice how the code won't run. Everything after the # symbol is ignored by Python, including any code.

There was meant to be an ad here. Support us by turning off your ad blocker or donating.