Tools, FAQ, Tutorials:
Multi-line Statements in Python Code
How to enter a single statement in multiple lines in Python Code?
✍: FYIcenter.com
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'
⇐ Basic Structure of Python Code
2023-06-12, 1430🔥, 0💬
Popular Posts:
How to use "json-to-xml" Azure API Policy Statement? The "json-to-xml" Policy Statement allows you t...
How To Access a Global Variable inside a Function? in PHP? By default, global variables are not acce...
How To Control Vertical Alignment? By default, text in all table cells are aligned to the top vertic...
What's Wrong with "while ($c=fgetc($f)) {}" in PHP? If you are using "while ($c=fgetc($f)) {}" to lo...
How to convert JSON Objects to PHP Associative Arrays using the json_decode() function? Actually, JS...