0

Can a sentence in Python finally be written in multiple lines?

I thought in Python a sentence should be always written in one line, and in this example (with '{}' in multiple lines) it is exactly like a hash-like way in Perl, only except without a final ';'. Must the indent be like that, or can be changed somehow? Is this still deemed as one sentence?

31st Oct 2016, 3:51 PM
Zsjit Ngiam
Zsjit Ngiam - avatar
2 Answers
+ 2
Python uses "statements"; a "sentence" is related to text/strings (the other answer takes that route). Line continuation (across multiple lines) for statements occurs implicitly with [, (, and { at least. It's explicit if you end a line with \ (which works inside strings and doesn't need to be closed like brackets do). https://www.python.org/dev/peps/pep-0008/#block-comments That style guide discusses how to line up the ending ])} and code inside the brackets.
1st Nov 2016, 4:23 PM
Kirk Schafer
Kirk Schafer - avatar
0
You may use: #1: s = “ “ “ this is a very long line if you want to write in python and more ......... “ “ “ Or you may use: #2: s = (“ this is a very” “ long line if you want to” “write in python and more ......... “
31st Oct 2016, 3:57 PM
Shovan Lal Saha
Shovan Lal Saha - avatar