How to Create a Comment Block on Jupyter Notebook

Follow these steps to create a block comment to your Jupyter notebook:

  1. First, launch a Jupyter Notebook in a web browser.
  2. Select the lines of code that you want to include in the block comment.
  3. To create the block comment, select multiple lines and then type # at the beginning of each one.


The #(pound) symbol adds a comment block to a code section in Python. The compiler treats as a comment any line of code that begins with #.

Let’s say you have an file with the following line of code.

def multiply(x, y): 
  return x * y

You can create a block comment by selecting the lines of code and typing # at the beginning of each line in Jupyter Notebook.

# def multiply(x, y):
#   return x * y

The above code will create a block comment in your Jupyter notebook, and the interpreter will ignore everything within the block.

Shortcut to do comment block on Jupyter notebook

Use the Ctrl + / shortcut command in Jupyter Notebook in Chrome browser in MS Windows.

On a Mac, use the CMD + / command to comment out the block of code in Jupyter Notebook.

That’s it for this article.

Further reading

Python comment block on Visual Studio Code

How to Write Single Line Comment Block in Python


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.