Download Article
Download Article
Quickly turn multiple lines into comments in Python
Trying to comment out a block of code in Python? There are multiple easy methods to do so! You can use the hash character # or turn the lines into a string. The keyboard shortcut for turning lines into code varies depending on the text editor you’re using. This wikiHow shows you how to comment out multiple lines in Python.
Things You Should Know
- Place a # and a space before each line of code.
- Alternatively, place """ before and after the block of code.
- To use a keyboard shortcut, select the block of code, then press the key combination.
Steps
Community Q&A
Search
-
QuestionHow to apply # on all lines of code?BhoimusTop AnswererFirst, select the entirety of the code using Ctrl+A. Then, use the keyboard shortcut for commenting code set for your IDE. Default key combinations for popular IDEs are given in the last step above.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
Video
Tips
- Keep Python regularly updated. You can check what version you’re using with the Python command line.Thanks
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
Advertisement
Expert Interview
Thanks for reading our article! If you’d like to learn more about computer programming, check out our in-depth interview with Kevin Burnett .
References
About This Article
Thanks to all authors for creating a page that has been read 70,617 times.
Advertisement