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 + \

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

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