In Jupyter notebooks you can toggle/comment a block of selected code with ^/
(ie Cntrl-/
) .. this doesn't work in Google Colab notebooks. Is there a way to comment out several lines of Python code easily in a Colab notebook?
I've looked in the docs, but come up short.
Using multiple single # line comments to add a block comment in Python. The most common way to comment out a block of code in Python is using the # character. Any line of code starting with # in Python is treated as a comment and gets ignored by the compiler.
Useful Keyboard Shortcuts in Google Colab Command. Shortcut. Create cell. Command/Ctrl+M+B. Select all cells.
All you need to do, is select all the lines you want to comment and press Ctrl + / as shown in below video.
In the default Colab keyboard shortcuts, you can block comment text using Ctrl+/.
If this does not work for you, check Tools->Keyboard Shortcuts and search for "Comment Current Line" to see what the shortcut is within your current settings.
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