Python - Comments

Comments in Python are a way to document your code and make it easier for other programmers to understand your code. Comments are ignored by the Python interpreter and are not executed.

There are two ways to add comments in Python:

Single-line comments: Single-line comments start with the hash symbol #. Anything after the # symbol in that line is considered a comment. For example:

# This is a single-line comment
print("Hello, World!")  # This is another single-line comment

Multi-line comments: Multi-line comments are used when you want to add comments that span across multiple lines. In Python, there is no built-in way to create multi-line comments, but you can use a multi-line string as a workaround. For example:

"""
This is a multi-line comment.
You can use it to write long comments
that span across multiple lines.
"""
print("Hello, World!")

In the above example, the multi-line string is not assigned to any variable, so it is ignored by the interpreter.