Temporarily blocking a chunk of code (with #) from execution in Jupyter Notebook

Is there a shortcut for temporarily blocking a chunk of code from execution (with a comment #) in Jupyter Notebook? Thanks ahead.


You can turn the cells into raw text format with esc + r
and turn it back into a code cell with esc + y

Skip cells when running Jupyter Notebook scripts | Adam Dimech's Coding Blog.

Hi Sam! Thanks for your prompt reply. It looks like the shortcut you suggest doesn’t work for MacBooks.

Oh, didn’t know that.

You can also use the Cell dropdown at the top of the notebook. Cell → Cell Type → the type of cell you want.

Another way is to select the lines, and press Ctrl+/. This will comment or uncomment the selected lines.

1 Like

Thanks, Raymond! That’s the one for MacBook!:+1: