I\'m just starting out with Python 2.7 and I don\'t understand why something is happening:
In the following code, an embellished version of an example from the pytho
The break statement is pulling out of the loop, so the else statement will never be reached.
Put the break in the else clause instead, like so:
while True:
try:
x = int(raw_input("Please enter a number: "))
except ValueError:
print "Oops! That was not a valid number. Try again..."
else:
print 'Thanks,',x,'is indeed an integer'
break
print 'all done, bye'