Python Forum

Full Version: how to insert # to multiple lines?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.