***Welcome to ashrafedu.blogspot.com ***This website is maintained by ASHRAF***
***Use tabs for Content***

POSTS

    Lines and Indentation

    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"