Python Comments

Python Comments

we can use comments to explain the code. Let’s Create the first comment in our python code

Comments are started with # in python programing language

#This is my comment
print("Hello, Hacktube5!")

Inline Comments

we can use comments in a single line to explain the code like this

print("Hello, Hacktube5!") #This is my comment

we can also use comments to prevent the code 

# print("Hello hacktube5")
print ("Hello Users")

Multi-Line Comments

to add a multi-line comment you could insert # for each line Let’s take an example

#This is my comment
#written in test
#more than just one line
print("Hello, World!")

We have one more option for multi-line comments we can use “”” my code here “””

"""
This is a comment
written in
more than just one line
"""
print("Hello, World!")

Leave a Reply