python - how to break out of this while loop -
guys trying break out of while loop..
starterp=input("would rather torchik, mudkip, or bulbasaur? choose wisely.") if starterp=='torchik' or starterp=='torchik':         print("you have picked torchik!") if starterp=='mudkip' or starterp=='mudkip':         print("you have picked mudkip!") if starterp=='bulbasaur' or starterp=='bulbasaur':         print("you have picked bulbasaur!") i want program keep asking input if not enter 1 of choices. anytime enter right input matches 3 choices, break out of loop , continue next codes.
you have 2 issues code:
- you not have loop @ all.  should use while true
- you should use breakbreak out of loop
code:
while true:     starterp=input("would rather torchik, mudkip, or bulbasaur? choose wisely.")     if starterp=='torchik' or starterp=='torchik':             print("you have picked torchik!")             break     if starterp=='mudkip' or starterp=='mudkip':             print("you have picked mudkip!")             break     if starterp=='bulbasaur' or starterp=='bulbasaur':             print("you have picked bulbasaur!")             break     print("please pick actual pokemon") #let user know didn't pick valid option 
Comments
Post a Comment