Multi-Line Statements in Python

PythonServer Side ProgrammingProgramming

Statements in Python typically end with a new line. Python does, however, allow the use of the line continuation character (\) to denote that the line should continue. For example −

total = item_one + \
        item_two + \
        item_three

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

days = ['Monday', 'Tuesday', 'Wednesday',
       'Thursday', 'Friday']
raja
Published on 24-Jan-2020 15:49:35
Advertisements