Python Comments

What is Comment

Comments are an extremely useful concept in any of the programming language. Comments help to write the explanation of code logic in textual language to maintain code readability, mark futuristic code blocks and much more. It does not affect code outcome and commented lines of the code does not get executed.

How to comment in Python?

# symbol is used to comment Line of code in Python. Lines which are starting with # symbol won’t get executed.

Incase there is need to comment multiple lines of code in Python then below methods can be used –

  1. Each line which shall be commented should start with # character.

OR

2. Place “”” (3 double quotes) at the beginning of the first line to be commented and “”” (3 double quotes) at the end of the last line.

Example –

“”” This is Python program.

Multiline comment example

This is how it can be done”””

  • NOTE – Python does not give any syntax for multiline comments.

Video explanation with demonstration can be checked here

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *