I want to comment out a block of multiple lines in Jupyter Notebook, but can't find out how to do that in this current version.
It used to be in one of the drop down menus but is no longer there.
How do you comment out multi-line blocks of code at once?
This is not a duplicate because the solution given in the following link doesn't seem to work anymore:
How can I block comment code in the IPython notebook?
Ctrl + / does nothing.
All you need to do, is select all the lines you want to comment and press Ctrl + / as shown in below video.
Python does not have any built-in mechanism for writing multiline comments. To write multiline comments in Python, prepend a # to each line to block comments. That means writing consecutive single-line comments. Start every line with the # sign consecutively, and you will achieve multiline comments.
Capturing Output With %%capture IPython has a cell magic, %%capture , which captures the stdout/stderr of a cell. With this magic you can discard these streams or store them in a variable. By default, %%capture discards these streams. This is a simple way to suppress unwanted output.
Ctrl + / works for me in Chrome browser in MS Windows. On a Mac, use Cmd + / (thanks Anton K).
Please note, if /
did not work out of the box, try pressing the /
key on the Numpad. Credit: @DreamFlasher in comments to this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With