SDE 1 at Amazon Updated March 17, 2020, 2:01 p.m. ⋅ 36 views

How to create multiline comment in Python ?

Python doesn't officially support multiline comments. But there are mainly 2 ways to make multiline comment in Python.

  • Use multiple single line comments. Like this
    # this is line 1 of comment
    # this is line 2 of comment
    # this is line 3 of comment
  • Use triple quoted strings. Like this
    This is 
    a multiline comment.
    This can go 
    to multiple lines.

When triple quoted strings are not a docstring they are ignored. docstring are the first thing in a class / function / module.

Just keep in mind to properly indent the triple quotes. triple quoted comments are however not encouraged by python. It's recommended to use multiple single line comments.

arrow_upward Upvote

comment Comment

arrow_downward downvote

Go back to feed

HackersFriend Updates

View more


Nov. 28, 2018, 5:30 p.m.

Python from zero to hero

place Delhi

View details

Aug. 13, 2018, 5:30 p.m.

Python from zero to hero

place Bangalore ( HackersFriend office BTM Layout)

View details