While loop with or? Please help!

2007-01-25 Thread wd . jonsson
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) + \\

Re: While loop with or? Please help!

2007-01-25 Thread Ravi Teja
while usrinp != y or Y or N or n: PROBLEM Correct way: while usrinp != y or usrinp != Y or usrinp != N or usrinp != n: There has to be a boolean evaluation on both sides of or. Or in this case: while usrinp not in ['Y', 'y', 'N', 'n']: Ravi Teja. --

Re: While loop with or? Please help!

2007-01-25 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : 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)

Re: While loop with or? Please help!

2007-01-25 Thread Paul Rubin
[EMAIL PROTECTED] writes: while usrinp != y or Y or N or n: PROBLEM while userinp not in 'yYnN': ... Or maybe more generally: while userinp.lower() not in 'yn':# case independent test ... -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop with or? Please help!

2007-01-25 Thread Peter Otten
Bruno Desthuilliers wrote: and simplified again thanks to Python 'in' operator: while not usrinp.lower() in yn: But note that 'in' performs a substring search and therefore yn and would be accepted as valid answers, too. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop with or? Please help!

2007-01-25 Thread Bruno Desthuilliers
Peter Otten a écrit : Bruno Desthuilliers wrote: and simplified again thanks to Python 'in' operator: while not usrinp.lower() in yn: But note that 'in' performs a substring search and therefore yn and would be accepted as valid answers, too. Mmm, right. Thanks for the correction. =

Re: While loop with or? Please help!

2007-01-25 Thread Tim Williams
On 25/01/07, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Peter Otten a écrit : Bruno Desthuilliers wrote: and simplified again thanks to Python 'in' operator: while not usrinp.lower() in yn: But note that 'in' performs a substring search and therefore yn and would be accepted as

Re: While loop with or? Please help!

2007-01-25 Thread Paul Rubin
Peter Otten [EMAIL PROTECTED] writes: while not usrinp.lower() in yn: But note that 'in' performs a substring search and therefore yn and would be accepted as valid answers, too. Oh right, that's a recent change to the language, I think. OK: while not usrinp.lower() in list(yn): ... --

Re: While loop with or? Please help!

2007-01-25 Thread [EMAIL PROTECTED]
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():

Re: While loop with or? Please help!

2007-01-25 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : On Jan 25, 11:26 am, [EMAIL PROTECTED] wrote: (snip) #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:

Re: While loop with or? Please help!

2007-01-25 Thread Daniel
2007-01-25 11:26:09 [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED] 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