All pastes #970784 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-04-04 08:35 UTC
rendered paste body
#!/usr/bin/python

# while.py
# Daniel Dalton <d.dalton@iinet.net.au>
# Some more experimenting: my book says to use an else after the loop?
# Why use this else? Why not just write this code after the while loop is done?

read = True
number = 405

while read:
    guess = int(raw_input ("Enter a number:"))
    if guess == number:
        print "You got it!"
        read = False
    elif number < guess:
        print "Too high!"
    else:
        print "Too low!"
else: # any point to this?
    print "Some else thing"
    #Why use the 'else' key word? When you could just do what I did in version 1?
print "Loop end!"