How to use parenthesis (Implicit line continuation) In Python
In this type of multi-line statement, Implicit line continuation is used when you split a statement using either parenthesis ( ), brackets [ ], and braces { }.
Example:
In this example, we are initializing the list and the mathematical expression using the parentheses ( ), brackets [ ], and braces { } sign which is the implicit line continuation to continue the same line in the multiple lines in python programming.
Python3
# Initializing a string # using parentheis "()". g = (f "geeks" f "for" f "geeks" ) print (g) # Initializing a list using the # Implicit multi-line statement. list = [ 5 , 4 , 3 , 2 , 1 ] print () print ('Initializing a list using the\ Implicit multi - line statement', list ) # Initializing a mathematical expression # using the Implicit multi-line statement. add = ( 50 + 40 - 52 ) print () print ('Initializing a mathematical expression\ using the Explicit multi - line statement', add) |
Output:
w3wiki Initializing a list using the Implicit multi-line statement [5, 4, 3, 2, 1] Initializing a mathematical expression using the Explicit multi-line statement 38
Python – Multi-Line Statements
In this article, we are going to understand the concept of Multi-Line statements in the Python programming language.
Statements in Python:
In Python, a statement is a logical command that a Python interpreter can read and carry out. It might be an assignment statement or an expression in Python.