1whatever = input("Pick an integer > ")
2 try:
3 whatever_as_an_integer = int(whatever)
4 print("That was an integer.")
5
6 except ValueError:
7 print("That is not an integer.")
1inp = input('somrthing: ')
2
3if inp.isnumeric():
4 print('THat was a integer.')
5else:
6 print('That was not a integer.')
1whatever = input("Pick an integer > ")
2try:
3 whatever_as_an_integer = int(whatever)
4 print("That was an integer.")
5
6except ValueError:
7 print("That is not an integer.")
1def check_user_input(input):
2 try:
3 # Convert it into integer
4 val = int(input)
5 print("Input is an integer number. Number = ", val)
6 except ValueError:
7 try:
8 # Convert it into float
9 val = float(input)
10 print("Input is a float number. Number = ", val)
11 except ValueError:
12 print("No.. input is not a number. It's a string")