Learning Python: Programming and Data Structures- Tutorial 3- Code Structure: No Braces, Just Indentation



Python and Indentation


This is a controversial feature. There a no braces in Python. Indentation decides the blocks. Everything at the same level of indentation is considered to be as part of the same block.
This leads to cleaner code which is easier to read. Don't mix tabs and spaces for indentation. Stick to just one. The code looks something like this. 

def test(x,y)
    if x > 0 :
        print "x is positive"
    else if x < 0:
        print "x is negative"
    else
        print "x is zero"