Python Comments

In programming we use comments for –

  • Making our code more informative or illustrative to third person.
  • Making our code easy to understand and interpret.
  • Preventing some code lines to from execution.

Single Line Comments

We simply use Hashtag(#) in the beginning of a line to make it a single line comment, as mentioned below

Practical demonstration of how we can prevent a line in a code from execution by using comments is mentioned below. Hello string is not printed in output as we made that line a comment.

Multiline Comment

We can simple use Hashtag(#) before as many lines as we want to make multiline commenting as demonstrated below

Or we could use other way for multiline comments which is triple double or single quotes.

Leave a Reply

Your email address will not be published. Required fields are marked *