Thursday, April 18, 2024

Comments and Types of comments in python

Must read

  • Comments are very important  in  writing a program.
  • Python interpreter  ignores comment.
  • In python , commenting  is indicated by ‘#’ ,It is extended till the end of the physical line.
  • Though’ #’ indicates a comment , but when it is written along with string is not considered as a comment.
  • Python supports two types of comments.
  • Single line comments
  • Multi line comments

Single line comments

  • In this type of comment, hash(#) character is followed by the information that explains the further text.
  • In case user wants to specify a single line comment, then comment must start with (#)

Multi-line comments

  • In case if user has the comments that extend to multiple lines , One way of doing this is to use ‘#’ in the beginning of each line.
  • Multi-lined comments  should be given in triple quotes.
- Advertisement -

More articles


Please enter your comment!
Please enter your name here

- Advertisement -

Latest article