+ 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)

25th Jun 2020, 8:57 PM
Jacob Hicks
Jacob Hicks - avatar
3 Answers
+ 5
Because... or "Easy" ... always evaluates true. It has to be... or x == "Easy"
25th Jun 2020, 9:05 PM
Sandra Meyer
Sandra Meyer - avatar
+ 4
you could trying using; if x == "easy" or x == "Easy" #or if x in ["easy", "Easy"]:
25th Jun 2020, 9:04 PM
rodwynnejones
rodwynnejones - avatar
+ 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.
25th Jun 2020, 9:29 PM
Jacob Hicks
Jacob Hicks - avatar