Multiple line comment in Python

+1 vote

This question already has an answer here:

Is there a way to give multiple line comments in Python?

Jul 31, 2018 in Python by bug_seeker
• 15,510 points
1,145 views

2 answers to this question.

+1 vote
Best answer
Try this

''' This is a multiline comment. I can type here whatever I want. '''

Python does have a multiline string/comment syntax in the sense that unless used as docstrings, multiline strings generate no bytecode -- just like #-prepended comments. In effect, it acts exactly like a comment.

On the other hand, if you say this behavior must be documented in the official docs to be a true comment syntax, then yes, you would be right to say it is not guaranteed as part of the language specification.

In any case your editor should also be able to easily comment-out a selected region (by placing a # in front of each line individually). If not, switch to an editor that does.

Programming in Python without certain text editing features can be a painful experience. Finding the right editor (and knowing how to use it) can make a big difference in how the Python programming experience is perceived.

Not only should the editor be able to comment-out selected regions, it should also be able to shift blocks of code to the left and right easily, and should automatically place the cursor at the current indentation level when you press Enter. Code folding can also be useful.

Hope this would help.
answered Jul 31, 2018 by Priyaj
• 58,020 points

selected Aug 4, 2018 by Vardhan
+1 vote
yes,

you can use

"""

statement

statement

"""
answered Aug 4, 2018 by Abhishek
• 240 points

Related Questions In Python

0 votes
1 answer

Multiple line comment in Python

Try this ''' This is a multiline comment. I can ...READ MORE

answered May 31, 2018 in Python by charlie_brown
• 7,720 points
559 views
0 votes
1 answer

Multiple line comment in python

No, you can simply use triple codes ...READ MORE

answered Jun 28, 2018 in Python by v.liyyah
• 1,300 points
573 views
+1 vote
1 answer

How to comment multiple lines in Python?

Comments in Python begin with a # ...READ MORE

answered May 24, 2019 in Python by Nisa
• 180 points
1,138 views
0 votes
1 answer

How to catch multiple exceptions in one line in python?

From Python Documentation: An except clause may name multiple ...READ MORE

answered Dec 17, 2020 in Python by Gitika
• 65,770 points
5,109 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,443 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,078 views
+1 vote
1 answer

Reading a large file, line by line in Python

The correct, fully Pythonic way to read ...READ MORE

answered Aug 21, 2018 in Python by Priyaj
• 58,020 points
1,030 views
+2 votes
1 answer

How do you make a block comment in python?

''' This is a multiline comment. I ...READ MORE

answered Aug 23, 2018 in Python by Priyaj
• 58,020 points
970 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP