while loop - multiple condition

Chris Angelico rosuav at gmail.com
Sun Oct 12 19:13:04 CEST 2014


On Mon, Oct 13, 2014 at 4:08 AM, Shiva
<shivaji_tn at yahoo.com.dmarc.invalid> wrote:
> Why is the second part of while condition not being checked?
>
> while ans.lower() != 'yes' or ans.lower()[0] != 'y':
>      ans = input('Do you like python?')
>
>
> My intention is if either of the conditions are true the loop should break.
> But the condition after 'or' doesn't seem to evaluate.

The loop will continue while either part is true - that's what "or"
means. Is that what you intended it to be doing?

ChrisA



More information about the Python-list mailing list