Python Comment | Creating a Comment | multiline comment | example
Python comment
Comments will be used to create a case for Python code.
Comments will be used to make the code more legible.
Once the code is tested, comments will not stop the execution.
Make a comment
Comments begin with #, and Python may ignore them:
Examples
# This can be a comment
Print (“Hello, World!”)
Comments will be placed at the top of a line, and Python may ignore the rest of the line:
Examples
Print (“Hello, World!”) # This could be a comment
Comments could not find the text to clarify the code, this may also be used to prevent Python from executing code:
Examples
#print (“Hello, World!”)
Print (“Cheers, Met!”)
Multi-line comments
Python does not have a syntax for multi-line comments.
To add a multi-line comment, you can insert a # for each line:
Examples
# This can be a comment # One line has # more written (“Hello, World!”
Or, almost as mean, you would use a multi-line string.
Since Python can ignore string literals that are not assigned to a variable, you will add a multi-line string (triple quotes) to your code, and you will comment within:
Examples
“””
This is a comment
written in
More than just one line
“””
Print (“Hello, World!”)
Python can browse the code until the string is allocated to a variable, ignore it on the other side, and you have created a multi-line comment.
Related Python Post
Python Comment | Creating a Comment | multiline comment | example
- Python Comment | Creating a Comment | multiline comment | example
- Python Dictionary Introduction | Why to use dictionary | with example
- How to do Sum or Addition in python
- Python Reverse number
- find a common number in python
- addition of number using for loop and providing user input data in python
- Python Count char in String
- Python Last Character from String
- Python Odd and Even | if the condition
- Python Greater or equal number
- Python PALINDROME NUMBER
- Python FIBONACCI SERIES
- Python Dictionary | Items method | Definition and usage
- Python Dictionary | Add data, POP, pop item, update method
- Python Dictionary | update() method
- Delete statement, Looping in the list In Python
- Odd and Even using Append in python
- Python | Simple Odd and Even number