×

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
Other
Online Grocery Delivery Services Market Research Report: Growth, Share, Value, Trends, and Insights
The worldwide "Online Grocery Delivery Services Market" 2025 Research Report presents a...
By Tushar Jane 2025-05-20 05:18:11 0
Other
Energy Efficient Motor Market: Industrial Demand and Technological Advancements
Energy Efficient Motor Market Analysis The energy-efficient motor market has undergone...
By Reshama Patil 2025-06-06 06:14:40 0
Other
Germany FSRU Market Size, Strategic Insights & Growth Forecast, 2025
Germany FSRU Market Overview: Germany, renowned for its engineering prowess and commitment to...
By Reshama Patil 2025-06-03 05:43:58 0
Other
Precision Agriculture Market Thrives on Predictive Analytics
Precision Agriculture Market driven by IoT, AI tech advances, and rising cloud adoption in...
By Lisa Tate 2025-05-23 12:10:00 0
Food
What Is the Buffalo Desi Ghee Price 1kg? Get Real-Time Rates
If you’ve been searching for rich, nutritious, and aromatic ghee, you’ve likely come...
By DCc Ghee 2025-05-27 17:11:58 0