×

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
Autre
医薬品グレードのヨウ化メチレン分析レポート2025-2031:市場規模、シェア、成長率、業界動向
QYResearch株式会社(所在地:東京都中央区)は、最新の調査資料「医薬品グレードのヨウ化メチレン―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」を2025年6...
Par Xu Shuyun 2025-06-11 07:17:34 0
Autre
磁気レオロジー(MR)流体ブレーキ世界市場調査レポート:規模、成長戦略、トレンド予測2025-2031
QYResearch株式会社(所在地:東京都中央区)は、最新の調査資料「磁気レオロジー(MR)流体ブレーキ―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」を2025...
Par Qyresearch Jasmine1 2025-06-06 06:00:44 0
Autre
Wireless Access Control Market Research Report 2025-2034 - Industry Insights, Trends & Competitive Outlook
The most recent report published by Vantage Market Research indicates that the "Wireless Access...
Par Tushar Jane 2025-05-13 05:14:44 0
Information Technology
Start a Profitable Food Delivery Venture with Our Deliveroo Clone
The demand for food delivery services is skyrocketing in a world that’s getting more...
Par Simon Leo 2025-05-27 07:45:51 0
Information Technology
ティッシュペーパー包装機の世界市場規模:全体売上と需要分析予測2025~2031
ティッシュペーパー包装機世界総市場規模...
Par Qyresearch Jasmine1 2025-05-19 03:08:22 0