Logic problem on 14.12


#1


I have a logic problem:
Why is

if char == 'A' or char == 'a':

not the same as

if char == ('A' or  'a'):

In exercise 14.12 I receve for the first code: X b i r d i n t h e h X n d . . .
For the second one: X b i r d i n t h e h a n d . . .
So in the second the 'a' isn't replaced and I don’t get the difference.

I hope someone can explain this to me.
Thank you.


#2

parentheses are evaluated first, so then you get:

('A' or 'a')

which will give the one condition which evaluate to true, given both evaluate to true, you will get the first one.

then the condition is:

if char == 'A'

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.