Learn with Yasir

Share Your Feedback

Python Comments


Learn Python Comments

Comments

  • Comments are important for making code more readable and understandable, especially for other programmers who may need to read or modify the code.
  • Comments in Python are non-executable lines of code and ignored by the Python interpreter when the code is executed.

There are two main types of comments in Python:

  • Single-line comments: These comments start with the hash symbol (#) and extend to the end of the line.
# This is a single-line comment
print("Hello, World!")
  • Multi-line comments: These comments are enclosed in triple quotes (“”” or ‘’’).
"""
This is a multi-line comment.
It can span multiple lines of code.
"""
print("Hello, World!")

See also: