Online Courses

Comments example
Comments are little texts that can be added in code. They are created for programmers to read, not computers.  A comment is simply one or more lines of text that is not executed by the computer.

There are two ways to comment in Python: single line and multiline.

Single line comment
A single line comment starts with the number sign (#) character:

# This is a comment

For each line you want to comment, put the number sign (#) in front.

# print('This is not run')

Multiline comment
Multiple lines can be created by repeating the number sign several times:

# This is a comment
# second line
x = 4

but this quickly becomes impractical.  A common way to use comments for multiple lines is to use the (”’) symbol:

''' This is a multiline 
Python comment example.'''
x = 5