×

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.

Search
Nach Verein filtern
Read More
Home
Seasonal Home Maintenance Checklist: What to Do Every Spring and Fall
Keeping your home in top shape isn’t just about appearance—it's about preventing...
Von Wooden Street 2025-06-02 12:23:35 0
Other
Europe Renewable Power Market Outlook: Technology, Players, and Demand Trends
Europe Renewable Electricity Market Analysis: Europe Renewable Electricity Market to grow...
Von Reshama Patil 2025-06-09 08:59:12 0
Information Technology
8 Steps to Improve Digital Marketing Results
Everyone wants to get the top slot in SERPs, but there is much to do to achieve the desired...
Von Jimmy Anderson 2025-05-27 08:08:41 0
Electric
In Glock We Trust Hoodie: Streetwear’s Unfiltered Anthem of Survival
Introduction: Where Cotton Meets Conviction There are hoodies that keep you warm. Then there are...
Von Vertabraec Vertabraec 2025-05-30 17:38:01 0
Food
Beyond Basic Baking: Exploring the Expanding Functional Flour Industry
The global food industry is undergoing a significant transformation, driven by health-conscious...
Von Ava Thomas 2025-05-21 09:11:20 0