In Python, you can make comments using the hash symbol (#).
Any text that appears after the hash symbol (#) on the same line is considered a comment and is ignored by the Python interpreter.
For example:
# This is a comment
print("Hello, world!") # This is also a comment
In the above example, the first line is a comment, and it is ignored by the Python interpreter. The second line is a print statement, which will print “Hello, world!” to the console when executed. The third line is another comment, which is also ignored.
You can also use multi-line comments by enclosing them in triple quotes (“”” “””). For example:
"""
This is a multi-line
comment in Python.
"""
print("Hello, world!")
In this example, the first three lines are a multi-line comment, and they are ignored by the Python interpreter. The fourth line is a print statement, which will print “Hello, world!” to the console when executed.
Leave a Reply