×

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.

Site içinde arama yapın
Kategoriler
Read More
Information Technology
業務用フードタイプ食器洗浄機業界の最新市場動向:売上、価格、販売数量の分析レポート2025
QYResearch株式会社(所在地:東京都中央区)は、最新の調査資料「業務用フードタイプ食器洗浄機―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」を2025年5月...
By Qyresearch Jasmine1 2025-05-12 05:40:02 0
Other
Locksmith near me
When you're locked out of your home, office, or car, searching for a “locksmith near...
By Ali Raza 2025-05-24 14:22:58 0
Information Technology
The Automobile Half Bridge Drivers Market
IntroductionThe Automobile Half Bridge Drivers Market is experiencing significant...
By HARSH Verma 2025-06-08 17:58:41 0
Other
Bakuchiol Market Analysis and Growth Opportunities 2025-2034 Forecast
The most recent report published by Vantage Market Research indicates that the "Bakuchiol Market"...
By ASHWINI GOURKHEDE 2025-05-08 05:00:32 0
Other
コードレスエアラチェットレンチの世界市場調査レポート:規模、現状、予測2025-2031
2025年6月9日に、QYResearch株式会社(所在地:東京都中央区)は、「コードレスエアラチェットレンチ―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」の調査...
By Qyresearch Jasmine1 2025-06-09 09:22:34 0