Python Forum

Full Version: Do I always have to use triple quotes or \n for multi-line statements?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Which multi-line statements do not require me to use triple quotes or \n? I am new to Python. Thanks for answering.
You can also use parenthesis/brackets/braces to imply line continuation (start a multi line)
var = (
    'some long string'
    'that just keeps going'
    'and going'
)
Output:
some long stringthat just keeps goingand going
Dont add commas otherwise you created a tuple.
Quote:
Output:
('some long string', 'that just keeps goingand going') ('some long string', 'that just keeps going', 'and going')

To be more complete there is also backslash
var = 'some long string' \
    'that just keeps going' \
    'and going'
I still prefer triple quotes though because then you dont need quotes on each line which could be add or removed at any time making more work. Also it is less keystrokes. I also hate the appearance of backslash.
Thanks for answering. I was wondering, are there any multi-line statements that do not require the use of triple quotes or \n?
that is multi-line statements without using triple quotes or newline characters.