Python provides no
braces to indicate blocks of code for class and function definitions or flow
control. Blocks of code are denoted by line indentation, which is rigidly
enforced.
The number of spaces in
the indentation is variable, but all statements within the block must be
indented the same amount.
In Python all the
continuous lines indented with same number of spaces would form a block.
Example:
if True:
print "True"
else:
print "False"
The following block generates an error
if True:
print
"Answer"
print "True"
else:
print
"Answer"
print "False"
No comments:
Post a Comment