+ 7
You can envelope the input part of your code in the while loop with a try/except phrase within, to ensure that the input is a number, ultimately. With that done, you might get down to 'if' statements.
2nd Apr 2017, 9:46 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 1
because when u enter a string, the first line tries to convert it to an int, so it crashes the program
2nd Apr 2017, 9:39 PM
Edward
+ 1
try: age = int(input("Please enter age:")) except ValueError: print("please enter a number") if age >= 18: print("access granted") else: print("denied")
3rd Apr 2017, 2:19 AM
Martian1oh1
Martian1oh1 - avatar