How to extend statement to multiple lines

Add \ to the end of statement

Expressions and statements can span several lines.



print \
 'Hello, world' 

The code above generates the following result.

Creating MultiLine Statements


total_sum = sum_item_one + \
            sum_item_two + \
            sum_item_three

Statements contained within the [], {}, or () brackets do not need to use the line continuation character.


week_list = ['Monday', 'Tuesday', 'Wednesday',
             'Thursday', 'Friday']




















Home »
  Python »
    Language Basics »




Python Basics
Operator
Statements
Function Definition
Class
Buildin Functions
Buildin Modules