Google News
logo
Python Comments
Python programs get bigger and more complicated, they get more difficult to read. Comments are very important while writing a program. Formal languages are dense, and it is often difficult to look at a piece of code and figure out what it is doing, or why.

In Python, we use the hash (#) symbol to start writing a comment. 

Everything after "#" on a line is ignored. No block comments, but doc strings are a comment in quotes at the beginning of a module, class, method or function. Also, editors with support for Python often provide the ability to comment out selected blocks of code, usually with "##".

Python Programming language comments are following...

Python supports two types of comments:

1) Single lined comment :

In case user wants to specify a single line comment, then comment must start with ?#?

Single Line Comments

2) Multi lined Comments :

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

#This is
#educational website.
#URL is freetimelearning.com

Another way of doing this is to use triple quotes, either ''' or """.

These triple quotes are generally used for multi-line strings. But they can be used as multi-line comment as well. Unless they are not docstrings, they do not generate any extra code.

""" This is
educational website.
URL is freetimelearning.com """
Multi Line Comments