Python functions have no explicit begin or end, and no curly braces to mark where the function code starts and stops. The only delimiter is a colon (:) and the indentation of the code itself.

This corresponds with def and if etc.

For example,

def fib(n):                   1
    print 'n =', n            2
    if n > 1:                 3
        return n * fib(n - 1)
    else:                     4
        print 'end of the line'
        return 1
© 2011 Web Oom Suffusion theme by Sayontan Sinha
Switch to our mobile site
Top Footer