mercredi 7 octobre 2015

Making a variable integer input only == an integer in Python

Im trying to make my variable integer input to be only == to an integer, and if its not I want to print and error message. I have put this in a if statement. I always get an error when I input a string instead of my error message.

age = int(input("Enter age:"))

if age != int:
print("Not a number")

Aucun commentaire:

Enregistrer un commentaire