I need vastus to be recognised as a number, or int or float type. So if i input vastus as -2 it goes to else statment but i need it to go to if statment. When i type any negative number it is recognised as a str. If there is any better way to slove it i would appriciate the help. I tried google and got nothing, still a total noob.
vastus = (input("Vastus:"))
print (type(vastus))
if vastus.isnumeric():
if float(vastus) == (a+b):
print ("Õige vastus")
tulemus = tulemus + 1
arv = arv + 1
else:
print ("Vale vastus, õige vastus on" ,(a+b))
arv = arv + 1
else:
print ("Peate sisestama arvu")
Aucun commentaire:
Enregistrer un commentaire