Hello guys. How are you all? I hope you all fine. In this tutorial we will learn about How to comment a Block of Code in Python. so without wasting time lets learn about of this.
How to comment a Block of Code in Python
- comment a Block of Code in Python
to comment a Block of Code in Python just Use #.By using# you can comment out the single line and block the comment of code. lets learn this by given example:
#print("hello guys") print("Have a good day!")
Output :Have a good day!
- How to comment a Block of Code in Python
to comment a Block of Code in Python just Use triple quotes.The triple quotes use for to comment out the multiple lines. So by using triple quotes you can comment out the multiple line and block the comment of code. lets learn this by given example:
"""print("hello guys") """ print("Have a good day!")
Output :Have a good day!
- how to comment out multiple lines in python
To comment a Block of Code in Python just Use triple quotes.The triple quotes use for to comment out the multiple lines. So by using triple quotes you can comment out the multiple line and block the comment of code. lets learn this by given example:
"""print("hello guys") """ print("Have a good day!")
Output :Have a good day!
Method 1: Use #
By using# you can comment out the single line and block the comment of code. lets learn this by given example:
#print("hello guys")
print("Have a good day!")
Output :
Have a good day!
Method 2: Use triple quotes
The triple quotes use for to comment out the multiple lines. So by using triple quotes you can comment out the multiple line and block the comment of code. lets learn this by given example:
"""print("hello guys")
"""
print("Have a good day!")
Output :
Have a good day!
Method 3: Use if False
By using if False you can comment out the line and block the comment of code. lets learn this by given example:
if False:
print("hello guys")
print("Have a good day!")
Output :
Have a good day!
Conclusion
It’s all About this Tutorial. Hope all methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you?
Also, Read