×

To install this app on your iPhone, tap Share 🔗 then Add to Home Screen.

05 How to write comments in Python?

0
41

Like other programming languages Python also has commenting capability for the purpose of in-code documentation.

Single Line Comment:

Comments start with a #, and Python will render the rest of the line as a comment: 

Example:

#This is a comment.
print("Hello, World!")

Or

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

Multy-Line Comment:

In-fact Python does not have any syntax for multi-line comments. To add a multiline comment you could insert a # for each line:

Example:

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

Or, you can also use a multiline string for multi-line comment.

Python ignores string literals that are not assigned to a variable, you can add a multiline string (triple quotes) in your code, and place your comment inside it.

Example:

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

As long as the string is not assigned to a variable, Python will read the code, but then ignore it, and you have made a multiline comment.

Search
Nach Verein filtern
Read More
Other
HR Payroll Software Market Share, Size & Growth Forecast by 2034
The worldwide "HR Payroll Software Market" 2025 Research Report presents a professional and...
Von ASHWINI GOURKHEDE 2025-05-16 05:30:38 0
Other
IP Telephonic Market Analysis and Growth Opportunities 2025-2034 Forecast
The worldwide "IP Telephonic Market" 2025 Research Report presents a professional and complete...
Von Tushar Jane 2025-05-13 05:13:53 0
Home
Electric vs. Manual Recliners: What’s the Right Choice for You?
A recliner isn't just a piece of furniture—it's a commitment to comfort. Whether...
Von Wooden Street 2025-05-28 09:01:48 0
Home
Flooring Installation: What Every Homeowner Should Know
Installing new flooring is a significant home improvement that can completely transform your...
Von Jason Watsom 2025-06-04 06:23:45 0
Other
Dental Turbines Market Research, Review, Applications and Forecast to 2025
The worldwide "Dental Turbines Market" 2025 Research Report presents a professional and complete...
Von ASHWINI GOURKHEDE 2025-06-10 06:16:32 0