Multi-line Statements in Python Code
How to enter a single statement in multiple lines in Python Code?
By default, Python uses the end of line to end a statement. So normally, you enter a statement in a single line.
But if you have a very long statement, you can enter a single statement in multiple lines in two ways:
1. Explicit line breaks - Using the backward slash character "\" to break a long statement into multiple lines. For example:
>>> 1 + 2 + 3 + 4 + \ ... 5 + 6 + 7 + 8 36
Note that in the Interactive mode, Python changes the prompt to "..." if the statement is not completed in the previous line.
2. Implicit line breaks - Breaking lines within parentheses or triple quotes. Python automatically continues to subsequent lines searching for the closing parenthesis or ending quotes. For example:
>>> (1 + 2 + 3 + 4 + ... 5 + 6 + 7 + 8) 36 >>> """Welcome ... to FYIcenter.com ... """ 'Welcome\nto FYIcenter.com\n'
2017-09-12, 208👍, 0💬
What Is an HTML "em" Tag/Element? An "em" element is an inline element that you can use to specify t...
What Is an HTML http-equiv "meta" Tag/Element? a http-equiv "meta" element is a special "meta" eleme...
Where to find tutorials on how to use PHP built-in functions to manage arrays? A collection of tutor...
How To Create a Table To Store Files in PHP? If you using MySQL database and want to store files in ...
Where to find tutorials on RSS specifications? I want to learn it to describe my API services. Here ...