Loading...
Loading...
00:00:00

Write Comments In Python3

What Is Comment?

In python programming language, comments are used to write the additional information about the written code for developers to understand the meaning of that code . Using the comments we can explain the written code. Comments is not treated as part of python code. when python interpreter execute the python code comments will be ignore. In python, comments starts with # symbol . we can use string literal for commenting the code in python. we can write comments multiple ways -

In Python, there are two types of comments:

  1. Single-line comments: These are comments that occupy only one line and are denoted by the # symbol. For example:
    # 1. this is comment is python 
    print("hello World")
  1. Multi-line comments: These are comments that span multiple lines and are denoted by triple quotes (either single quotes ''' or double quotes """). For example:
    " 2. This is string as comment in python"
    
    """ 3. This is doc string as multiline comment
     in python
     print("comment")
      """ 
    print("hello World")
    Both single-line and multi-line comments are used to add annotations, explanations, or documentation to the code. They are ignored by the Python interpreter and do not affect the execution of the code.