Python Comments


Python Comments

Python Comment is an essential tool for the programmers. Comments are generally used to explain the code. We can easily understand the code if it has a proper explanation. A good programmer must use the comments because in the future anyone wants to modify the code as well as implement the new module; then, it can be done easily.

In the other programming language such as C++, It provides the // for single-lined comment and /*.... */ for multiple-lined comment, but Python provides the single-lined Python comment. To apply the comment in the code we use the hash(#) at the beginning of the statement or code.

Types Of Comments

  1. Singleline Python Comment
  2. Multiline Python Comment

Singleline Python Comment

Comments starts with a #

#This is a comment
print("Hello, World!")


Multiline Python Comment 

Python does not really have a syntax for multi line comments.We must use the hash(#) at the beginning of every line of code to apply the multiline Python comment. 

#This is a comment
#written in
#multilline
print("Hello, World!")

Post a Comment

0 Comments