Tutorials  Articles  Notifications  Login  Signup


Anoop Singh

SDE 1 at Amazon Updated March 17, 2020, 2:01 p.m. ⋅ 816 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.

HackerFriend Logo

Join the community of 1 Lakh+ Developers

Create a free account and get access to tutorials, jobs, hackathons, developer events and neatly written articles.

Create a free account