On Jan 25, 11:26 am, [EMAIL PROTECTED] wrote:
> 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

also note that your naming of variables contains two different names
for one variable...

better

usrinp = ''
while usrinp.lower() not in ('y', 'n'):
        usrinp = raw_input('Y/N: ') # and not usr....

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to