
Hello Greg, thanks for your email.
On Sat, Jun 23, 2012 at 11:51 PM, Greg Edwards gedwards2@gmail.com wrote:
Hi,
At http://docs.python.org/release/2.7.3/tutorial/errors.html sect 8.3, the first example block should ask the user for an "integer", not just a "number". I happily entered 1.23 without thikning too much and it failed.
If you enter 1.23 you've just tested the except branch:
while True:
... try: ... x = int(raw_input("Please enter a number: ")) ... break ... except ValueError: ... print "Oops! That was no valid number. Try again..." ... Please enter a number: 1.23 Oops! That was no valid number. Try again... Please enter a number:
As far as I can see, the example works as expected, and there's nothing wrong with it (not even the imprecise indication of what number to enter).
Cheers,