-2

I am wondering, if its possible comment many lines at once in Python Jupyter Notebook or/and Spyder.

What I mean is to change this:

x=2
y=3
z=4
x=3
y=4
z=5

Into this

#x=2
#y=3
#z=4
x=3
y=4
z=5

Is it possible? It would speed up my work many times :)

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Kuba
  • 291
  • 2
  • 5
  • 14

1 Answers1

0

Not entirely sure that I understood correctly, but this available per editor.

For example, in each editor you'll have a shortcut for commenting out/in lines at once, so it depends on the editor.

In Jupyter for example, you can use Ctrl + / which works for me.

As if you're writing just in a simple notepad, I can however suggest the following three single-quotes at the start and at the end.

For example:

'''x=2
y=3
z=4
x=3'''
y=4
z=5

So the part from x=2 to the part of x=3 is currently commented out from the code and won't be executed.

Avihoo Mamka
  • 4,656
  • 3
  • 31
  • 44