+ 1
What am I doing wrong on this while loop?
It always uses the first if statement def difficulty_Level(xp): x = input("""Easy, Normal, or Hard? """) multiplyer = 0 while True: if x == "easy" or "Easy": multiplyer = 0.5 break elif x == "normal" or "Normal": multiplyer = 1.0 break elif x == "hard" or "Hard": multiplyer = 2.0 break else: print("try again") xp = xp * multiplyer return xp total_exp = difficulty_Level(100.0) print(total_exp)
3 Answers
+ 5
Because...
or "Easy"
... always evaluates true. It has to be...
or x == "Easy"
+ 4
you could trying using;
if x == "easy" or x == "Easy"
#or
if x in ["easy", "Easy"]:
+ 2
Of course the one thing I didn't consider. Not only that, but because of your solutions, I realized that the input should be in the while loop.
Thank you very much.