I´m still new to python and trying to convert a string user input to an integer. My code looks like that:
var_input = input("Please input XX for a or YY for b:")
while True:
try:
if var_input == "XX":
var_v = 1
elif var_input == "YY":
var_v = 0
break;
except ValueError:
print("Invalid Input")
I´m always ending up with var_v = 0
I´m sure there is a really simple way but i don´t get there.
Thankful for any help!
Aucun commentaire:
Enregistrer un commentaire