VOOZH about

URL: https://www.geeksforgeeks.org/python/python-comments/

⇱ Python Comments - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python Comments

Last Updated : 27 May, 2026

Comments in Python are used to add explanatory notes to code and are ignored during program execution.

  • 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.

Single Line Comments

Single line comments starts with hashtag symbol #.


Output
geeksforgeeks

Multi-Line Comments

Python does not have a dedicated syntax for multi-line comments. However, they are commonly written using multiple # symbols or unassigned string literals.

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.

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. 

Comment
Article Tags: