I am trying to test a function I found here: http://docs.python.org/3/tutorial/errors.html (section 8.3 Handling Exceptions).
With this function, we can check if a number is an integer:
x = int(input("Please enter a number: "))
print(“Oops! That was no valid number. Try again…”)
I’ve got some problems:
When I type “109poit”, I’ve got this error message:
“Unexpected token ‘poit’”
When I type “109asdrgfase5”, I’ve got this error message:
“name ‘109asdrgfase’ is not defined”
When I type “109l” it works, whereas it’s not an integer! As a consequence, when I type “109loit”, I’ve got the error message: “Unexpected token ‘oit’”, whereas I should get “Unexpected token ‘loit’”.
I seems to act like that only with the letter “l”!!
So I really don’t get anything. What’s more it’s a function found in the help guide, so I shouldn’t have so many problems with this routine!
Thank you for helping me.