Python Forum

Full Version: Unexpected input within a while loop
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In this preliminary while loop, the user is asked to input an advantage. If they input 1,2, or 3 they while loop should say "Your stats been updated" and it does. But it also does for anything else, which I don't want it to do. Any help is appreciated.

valid = {'1', '2', '3'}
advantage = " "
while advantage not in valid:
    advantage = input("Do you pick extra health [1], extra luck [2], or extra power [3]")

    break

print ("Your stats have been updated")
Thanks in advance
remove the break
Larz60+ solution woks, but just for completeness, here is an example of the loop using the break. You mix the two approaches in your code
valid = {'1', '2', '3'}
while True:
    advantage = input("Do you pick extra health [1], extra luck [2], or extra power [3]")
    if advantage in valid:
        break
print ("Your stats have been updated")