while loop - multiple condition

Chris Angelico rosuav at gmail.com
Mon Oct 13 13:59:00 CEST 2014


On Mon, Oct 13, 2014 at 7:31 PM, Gelonida N <gelonida at gmail.com> wrote:
> Taking into account the Steven's suggestion about using the 'in' expression
> it could be:
>
>
> while True:
>     ans = input('Do you like python?')
>     if ans.lower() in ('yes', 'y'):
>         break

Or, even simpler: Use an active condition.

while input('Do you like python?') not in ('yes', 'y'): pass

ChrisA



More information about the Python-list mailing list