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
  • 249
  • 1
  • 4
  • 23

1 Answers1

4

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,344
  • 1
  • 10
  • 21