Many times coder want to document the functions or variable inside the code block. So they have to comment on the text. If you want to comment out multiple lines in Jupyter Notebook then how you will do so? In this tutorial, you will learn How to Comment out Multiple Lines in Jupyter Notebook.
Methods on How to Comment out Multiple Lines in Jupyter Notebook
To comment out multiple lines in Jupyter Notebook, you can use the following methods:
Method 1: Using keyboard shortcuts
For Windows and Linux
On Windows, you will Select the lines you want to comment on, then press
Ctrl + /.
In the macOS, select the lines you want to comment on, then press
Cmd + /.
Method 2: Using the code editor toolbar:
Select the lines you want to comment on. After that click on the comment button (
#) in the toolbar at the top of the code cell. This will add a
# character at the beginning of each selected line, commenting them out.
Method 3: Manually adding # at the beginning of each line:
Place the cursor at the beginning of the first line you want to comment out, then press the
# key. Repeat this step for each line you want to comment out.
You have to use comments on every piece of code to make the code more readable. It also helps you in debugging, and testing by commenting out the lines of codeThe above are the methods to comment on multiple lines in Jupyter Notebook.