It is mainly used to make the code more understandable and readable. Comments can be used to prevent execution while testing the code
CREATING A COMMENT
- Comments are supposed to start with # and the Python interpreter should ignore it.
- Python does not, supposedly, have a standard syntax for the multiline comments. To add a multiline comment we can use a # at the start of each line.
- We can even use a multiline string since we know python ignores any string literals if it is not assigned to any variable, we can add a multiline string using triple quotes and place the comment using it.
- Python does not, supposedly, have a standard syntax for the multiline comments. To add a multiline comment we can use a # at the start of each line.
- We can even use a multiline string since we know python ignores any string literals if it is not assigned to any variable, we can add a multiline string using triple quotes and place the comment using it.
Example No.1:
print("Knowledge2life online website")
#Kowleddge2life this is comment
OUTPUT:
Knowledge2life online website
Example No.2:
#Website
print("Knowledge2life online website")
#Kowleddge2life this is comment
OUTPUT:
Knowledge2life online website