Python Comments

Last Updated : 17 Jan, 2026

Comments in Python are the lines in the code that are ignored by the interpreter during the execution of the program.

  • It enhance the readability of the code.
  • It can be used to identify functionality or structure the code-base.
  • It can help understanding unusual or tricky scenarios handled by the code to prevent accidental removal or changes.
  • It can be used to prevent executing any specific part of your code, while making changes or testing.
python
# I am single line comment

""" Multi-line comment used
print("Python Comments") """


Single Line Comments

Single line comments starts with hashtag symbol #.

Python
# sample comment
name = "geeksforgeeks"
print(name)

Output
geeksforgeeks

Multi-Line Comments

Python does not provide the option for multiline comments. However, there are different ways through which we can write multiline comments.

1. Using multiple hashtags (#)

We can use multiple hashtags (#) to write multiline comments. Each and every line will be considered as a single-line comment.

Python
# Python program to demonstrate
# multiline comments
print("Multiline comments")

2. Using String Literals

Python ignores the string literals that are not assigned to a variable. So, we can use these string literals as comments. 

Python
'Single-line comments using string literals'

""" Python program to demonstrate
 multiline comments"""
print("Multiline comments")
Suggested Quiz

0 Questions

Image
Quiz Completed Successfully

Your Score : 0/0

Accuracy : 0%

Comment

Explore