×

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.

Buscar
Categorías
Read More
Shopping
Can the Right Fog Fluid Improve Your Smoke Machine’s Performance
When creating unforgettable stage effects, the fog fluid for smoke machines you use is just as...
By Rasha Professional 2025-05-08 09:48:42 0
Other
Enterprise Search Market Booming in Size in 2025
The most recent report published by Vantage Market Research indicates that the "Enterprise Search...
By Tushar Jane 2025-05-20 05:17:14 0
Other
Urology Devices Market Demand, Share, and Strategic Outlook - 2030
Urology Devices Market Projected to Expand at 7.2% CAGR Through 2030 The Global Urology...
By Ditoj Ditoj 2025-06-10 05:48:31 0
Other
Fixed Wireless Access (FWA) Market Research Report: Growth, Share, Value, Trends, and Insights
The most recent report published by Vantage Market Research indicates that the "Fixed Wireless...
By Tushar Jane 2025-05-13 05:14:52 0
Home
Affordable and Reliable Cleaning Services Woodbury MN!
Maintaining a clean home or office is essential not only for aesthetics but also for health and...
By RichClinxCare RichClinxCare 2025-06-05 14:53:59 0