while loop - multiple condition

Chris Angelico rosuav at gmail.com
Sun Oct 12 21:22:24 CEST 2014


On Mon, Oct 13, 2014 at 6:16 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> The corrected version
>
>     while ans.lower() != 'yes' and ans.lower()[0] != 'y':
>          ans = input('Do you like python?')
>
> is equivalent with
>
>     while ans.lower()[0] != 'y':

It's true that the first part is redundant, but trimming that out
wouldn't have taught the OP about boolean logic :)

ChrisA



More information about the Python-list mailing list