LINES, INDENTATION, AND MULTILINES
Unlike other programming languages (such as Java or Objective-C), Python uses indentation instead of curly braces for code blocks. Indentation must be consistent in a code block, as shown here:
if True:
print("ABC")
print("DEF")
else:
print("ABC")
print("DEF")
Multiline statements in Python can terminate with a new line or the backslash (“\”) character, as shown here:
total = x1 + \
x2 + \
x3
Obviously you can place x1, x2, and x3 on the same line, so there is no reason to use three separate lines; however, this functionality is available in case you need to add a set of variables that do not fit on a single line.
You can specify multiple statements in one line by using a semicolon (“;”) to separate each statement, as shown here:
a=10; b=5; print(a); print(a+b)
The output of the preceding code snippet is here:
10 15
Note: the use of semi-colons and...