Computer >> Computer tutorials >  >> Programming >> Python

How do we write Multi-Line Statements in Python?


In Python, the preferred way of wrapping long expression over multiple lines is to put it inside parentheses

Example

a=(10**2+
   10*5
   -10)
 print (a)

Output

This will result in 140.

Example

Another way is to use line continuation character

b=1+ \
   2 + \
   3
 print (b)

Note that even if items in List, Tuple or Dictionary object span over multiple lines, the line continuation character is not needed.