While loop with "or"? Please help!

Daniel not at set.se
Thu Jan 25 13:50:44 EST 2007


2007-01-25 11:26:09
wd.jonsson at gmail.com wrote in message
<1169720769.490434.91650 at j27g2000cwj.googlegroups.com>

> Hmm, my while loop with "or" doesn't seem to work as I want it to...

> How do I tell the while loop to only accept "Y" or "y" or "N" or 
"n"
> input from the str(raw_input)?
> 
> Thank's in advance!
> 
> Snippet of code:
> 
> import os
> 
> def buildfinder():
>     os.system("CLS")
>     GameRoot = os.getenv("GAME_ROOT") + "\\"
> 
>     print "Do you want to use " + GameRoot + " as your source
> directory?"
>     usr = str(raw_input('Y/N: '))
>     return usr
> 
> #Runs the buildfinder function
> usrinp = buildfinder()
> 
> def buildwhiler():
> 
>     while usrinp != "y" or "Y" or "N" or "n": <<<<----PROBLEM
>         print "Enter Y or N!"
>         usr = str(raw_input('Y/N: '))
>     else:
>         code continues

Thanks for the help everyone! :)
This forum rules!



More information about the Python-list mailing list