2

So I am trying for my program to print the message "That is not an integer!" if the user inputs something that is not an integer basically, I thought this was how you would do that but apparently isn't, could anyone tell me what I am doing wrong please?

user_number = input()
if type(user_number) != int:
  print("That's not an integer number.")
Okym
  • 239
  • 2
  • 5
  • 24

1 Answers1

3

You could try to convert the input to integer with try/except:

user_number = input()

try:
    int(user_number)
except:
    print("That's not an integer number.")
srikavineehari
  • 2,502
  • 1
  • 11
  • 21