Python Forum
how to insert # to multiple lines?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to insert # to multiple lines?
#1
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
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to insert Dashed Lines in between Rows of a tabulate output Mudassir1987 0 463 Sep-27-2023, 10:09 AM
Last Post: Mudassir1987
  How to write the condition for deleting multiple lines? Lky 3 1,099 Jul-10-2022, 02:28 PM
Last Post: Lky
  Delete multiple lines from txt file Lky 6 2,201 Jul-10-2022, 12:09 PM
Last Post: jefsummers
  Insert a multiple constant value after header in csv file using python shantanu97 1 1,114 Apr-24-2022, 10:04 AM
Last Post: Pedroski55
  Display table field on multiple lines, 'wordwrap' 3python 0 1,747 Aug-06-2021, 08:17 PM
Last Post: 3python
  pulling multiple lines from a txt IceJJFish69 3 2,522 Apr-26-2021, 05:56 PM
Last Post: snippsat
  Iterate 2 large text files across lines and replace lines in second file medatib531 13 5,705 Aug-10-2020, 11:01 PM
Last Post: medatib531
  print python json dump onto multiple lines lhailey 2 19,646 Mar-02-2020, 12:47 PM
Last Post: vishalhule
  Random nr. no repetition & printing multiple lines Joey 7 2,736 Feb-05-2020, 04:23 PM
Last Post: Larz60+
  KeyError -read multiple lines bongielondy 2 3,399 Nov-06-2019, 01:33 AM
Last Post: bongielondy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020