mercredi 10 mars 2021

How can you make an if statement that checks if input is a str/int

basically im new to python programming and I've just learnt about user input. Im trying to make an if statement that checks if the input is a str or int and then prints a message. If anyone knows how then please comment it, thanks.

print("How old are you?")
dog = input()
final = int(dog) + int(100)

if dog == str:
    print("No")
else:
    print("\nHeres you name + 100!")
    print(f"{final}")
    print("Thanks for playing!")

btw the if statement that I put doesn't work, I dont know if I need to put an exception so it responds with not an error message.

Aucun commentaire:

Enregistrer un commentaire