×

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.

Rechercher
Catégories
Lire la suite
Information Technology
EDCクラッキング炉世界市場調査レポート:規模、成長戦略、トレンド予測2025-2031
2025年5月22日に、QYResearch株式会社(所在地:東京都中央区)は、「EDCクラッキング炉―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」の調査資料を発...
Par Qyresearch Jasmine1 2025-05-22 06:44:43 0
Autre
String PV Inverter Market Size, Growth & Research Report (2025-2033) | UnivDatos
According to the UnivDatos Market Insights, the rise of renewable energy solutions and increasing...
Par Ahasan Ali 2025-05-12 13:04:24 0
Autre
総銅分析装置業界レポート:市場動向、機会分析、将来予測2025-2031
QYResearch株式会社(所在地:東京都中央区)は、最新の調査資料「総銅分析装置―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」を2025年6月6日より発行しま...
Par Xu Shuyun 2025-06-06 09:16:56 0
Autre
Best Digital Marketing Expert in Kochi
Best Digital Marketing Expert in Kochi | George Chacko – Digital Parrots Kochi Looking for...
Par Technology Welldone 2025-06-06 11:38:53 0
Autre
AI in Manufacturing Market Revenue and Share Study Analysis to 2034
The worldwide "AI in Manufacturing Market" 2025 Research Report presents a professional and...
Par Tushar Jane 2025-05-16 05:08:44 0