Ever needed to temporarily disable a chunk of Python code? Commenting out multiple lines is a lifesaver! But how do you do it efficiently? Python doesn't have a dedicated multi-line comment syntax like some other languages.
Fear not! There are two main methods:
1. **Using Triple Quotes:** Enclose the block of code within triple single quotes (''') or triple double quotes (""). Python interprets this as a multi-line string literal, effectively ignoring the code within.
```python
'''
print("This line won't run")
x = 10
print("Neither will this")
'''
```
2. **Prefixing with Hashtags:** Simply add a hashtag (#) at the beginning of each line you want to comment out. While more verbose, it's highly readable and explicitly shows each line is a comment.
```python
# print("This is also commented out")
# y = 20
# print("And this too!")
```
Choose the method that best suits your coding style and readability preferences. Happy coding!