How To Comment Code In Python (Multiple or Single Lines)

In this blog post, I will show how to comment on multiple or single lines of code in Python programming.


Commenting code is very useful when we write Python code as we add or remove features from our program.

Multiple lines of code commenting

For me commenting multiple lines of code is very useful because sometimes I like to remove blocks of code which I try new things.

Below is an example of how we comment on multiple lines of code.

We simply use, “””

print("Enter message")
get_input = input()

Single Line of code commenting

# get_input_2 = input("Please enter message")

Inline commenting

We can also add a comment after a line of code by placing the pound sign after the code as shown below.

get_input_3 = int(input("Please enter message")) #

Success! You're on the list.