I am trying to make a calculator in python. However, I want the user to be able to input an integer or float. But not a string, how can I do that?
This is my current code, however, the if statement does not do the intended job.
def calculator():
x = (input("Please enter a number: "))
y = (input("Please enter a second number"))
if x or y != int or float:
print("Invalid input, please enter a number")
x = input("Please enter a number: ")
y = input("Now, please enter a second number: Press enter to leave blank: ")
Aucun commentaire:
Enregistrer un commentaire