SiteMap  | About    

Python Fundamentals

How To Comment Python Code?

Comments are very important in computer programming . It describes what's going on inside a program so that a person looking at the source code does not have a hard time figuring it out. Comments in Python start with the hash character # and extend to the end of the physical line. Since comments are to clarify source code and are not interpreted by Python , they may be omitted when typing in examples.

The above line is not executed in Python .

Another example:

output is 30

Python Multiline comments

If we have comments that extend multiple lines, one way of doing it is to use hash (#) in the beginning of each line.

A common way to use comments for multiple lines is to use the triple-quoted strings(''') symbol.

Note: Python does not support multiline comments like C/C++ or .Net . However there is nothing to stop you to use multi-line docstrings as multiline comments . This is also mentioned by Guido van Rossum, the creator of Python. (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.