While loop with "or"? Please help!

Paul Rubin http
Thu Jan 25 13:57:15 CET 2007

Peter Otten <__peter__ at web.de> 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"): ...

More information about the Python-list mailing list