How do you comment out code in Python using multi-line comment?
Experience Level: Junior
Tags: Python
Answer
Python doesn't support multi-line comments.
The workaround is to prepend each line in the block that you want to comment out with the hash (#) character.
Example:
# This block of the code
# is commented out
# and it is not executed by Python.
print("and this is executed")
Related Python job interview questions
What is a static method in Python?
Python JuniorWhy should you convert your private class methods to static methods in Python whenever possible?
Python JuniorHow do you comment out code in Python using single-line comment?
Python JuniorHow do you delete an item from a list in Python?
Python JuniorHow do you add a new item to a list in Python?
Python Junior