A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python/python-comments/ below:

Python Comments - GeeksforGeeks

Python Comments

Last Updated : 12 Jul, 2025

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

python
# I am single line comment

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

In Python, single line comments starts with hashtag symbol #.

Python
# sample comment
name = "geeksforgeeks"
print(name)
Multi-Line Comments

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

Multiline comments using multiple hashtags (#)

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

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

Also Check: Interesting Fact about Python Multi-line Comments

Using String Literals as Comment

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

Python
'Single-line comments using string literals'

""" Python program to demonstrate
 multiline comments"""
print("Multiline comments")
Best Practice to Write Comments

These are some of the tips you can follow, to make your comments effective are:

  1. Comments should be short and precise.
  2. Use comments only when necessary, don't clutter your code with comments.
  3. Avoid writing generic or basic comments.
  4. Write comments that are self explanatory.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4