Python uses code indentation to identify code block

Using Code Indentation

The number of spaces in the indentation is variable, but all statements within the block must be indented the same amount.


if True:# from  w  ww.ja va 2  s . c om
    print "True"
    print "True"
    print "True"
else:
    print "False"
    print "False"
    print "False"

The code above generates the following result.





















Home »
  Python »
    Language Basics »




Python Basics
Operator
Statements
Function Definition
Class
Buildin Functions
Buildin Modules