[Tutor] while x != 'n' or 'N' or 'l' or 'L':

Brad Chandler mbc2@netdoor.com
Wed, 6 Dec 2000 09:58:32 -0600


> while x != 'n' or x != 'N' or x != 'l' or x != 'L':
>
> is *exactly* equivalent to:
>
> while 1:
>
> - it will *always* be true, and will loop forever. I suspect that you
mean:
>
> while x != 'n' and x != 'N' and x != 'l' and x != 'L':

Yeah, that's right. Apparently, I'm still struggling with this. My point,
though, was that there has to be a comparison with x after each 'and' or
'or', which is exactly what you stated in your first response. I was just
trying to show it in code because there are other situations where the
correct syntax is needed.


Brad