×

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
Wearable Payment Devices Market Growth and Forecast Analysis 2034
The worldwide "Wearable Payment Devices Market" 2025 Research Report presents a professional and...
Por ASHWINI GOURKHEDE 2025-05-21 06:08:05 0
Outro
Retained Earnings - Find Out Everything You Should Know
If you are reading this blog, it is certain that you have also been confused about the meaning of...
Por Info Accountinglads 2025-05-26 10:03:30 0
Information Technology
10 Ways AI is Changing the Game for Inventory Management
In an increasingly competitive and fast-paced world of logistics, effective inventory management...
Por Nisha Verma 2025-05-21 05:42:20 0
Outro
工業用高温耐性ポリイミドカバーフィルムの最新市場動向:業界成長率、競争環境、今後の見通し2025-2031
YH Research株式会社(本社:東京都中央区)は、「グローバル工業用高温耐性ポリイミドカバーフィルムのトップ会社の市場シェアおよびランキング...
Por Krystal Lin 2025-06-11 06:39:38 0