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:

  1. you not have loop @ all. should use while true
  2. you should use break break 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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -