While loop with "or"? Please help!

wd.jonsson at gmail.com wd.jonsson at gmail.com
Thu Jan 25 05:26:09 EST 2007


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




More information about the Python-list mailing list