×

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.

Pesquisar
Categorias
Leia mais
Outro
Pneumatic Rollers Market Unveiling Driving Factors, Strategies, and Forecasted Trends by Fact MR
The global pneumatic rollers market is expected to reach USD 1,419 million by 2035, up...
Por Akshay Gorde 2025-06-03 13:59:19 0
Outro
Comprehensive Guide to Spirit Airlines Corporate Headquarters and Southwest Airlines Flights to Palm Springs, CA
This Spirit Airlines Corporate Office Headquarters serves as the central hub for the airline's...
Por Ameliaa Smith 2025-05-23 07:09:46 0
Outro
Telemedicine Technologies Market Research Report: Growth, Share, Value, Trends, and Insights
The most recent report published by Vantage Market Research indicates that the "Telemedicine...
Por Tushar Jane 2025-06-10 05:38:09 0
Outro
Medical Waste Disposal UAE
Medical Waste Disposal UAE | Trusted Medical Waste Collection in Dubai – Dotless Looking...
Por Technology Welldone 2025-06-06 09:48:19 0
Outro
赤外線センサー調査レポート:市場規模、産業分析、最新動向、予測2025-2031
2025年6月3日に、QYResearch株式会社(所在地:東京都中央区)は、「赤外線センサー―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」の最新調査レポートを発...
Por Moni Ka 2025-06-03 05:43:15 0