Fork me on GitHub

Leslie Syntax Post

by Leslie Ho

28 Aug 2013

Hey guys, so just looking at some Python code and this was something that Java has, if-else statements, so here's some Python code for that:

if i < 20:
    print "That is less than 20."
    if i % 3 == 0:
        print "It is divisible by 3."
elif i == 20:
    print "That is exactly twenty.  How nice for you."
else:
    if i % 2 == 1:
        print "That is an odd number."
    else:
        print "That is twice", i / 2, '.'
    print "Wow! That's more than 20!"
Leslie is a BSIS and Anthropology double major. She really likes puppies. Find Leslie Ho on Twitter, Github, and on the web.
comments powered by Disqus