Python Forum
how to insert # to multiple lines? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: how to insert # to multiple lines? (/thread-23319.html)



how to insert # to multiple lines? - hkfatasy - Dec-22-2019

I just start to learn Phython by watching video online.
i saw people can add "#" to lines with hotkey,

i want to know how to do that

thanks bro


RE: how to insert # to multiple lines? - ichabod801 - Dec-22-2019

It's going to depend on what editor you are using, it's not a Python thing.

One thing that is a Python thing is triple quotes. A string that starts and ends with three quotes is a multi-line string, and is treated as a special kind of comment. So this:

for knight in camelot:
    # knight.sing()
    # knight.dance()
    # knight.do_routines()
    knight.footwork(impeccable = True)
print("It's only a model.")
Is equivalent to:

for knight in camelot:
    """knight.sing()
    knight.dance()
    knight.do_routines()"""
    knight.footwork(impeccable = True)
print("It's only a model.")
So it's an easy way to comment out multiple lines.