Syntax Error


#1

Hello everybody, my name is Francisco and looking for a little help here. I am currently learning Python and I do apologice but English is not my mother tongue.
I am over Conditionals & Control Flow chapter, lesson 10 (MIx´n´Match) which is about the three boolean operators studied so far “not, and, or” (the order is mine because is mnemonic.The right order in which the lessons are given is “and, or, not”). One of the exercises proposed is to make true a statement using at least one of these operators of your choice. Very playful! I went through quite o.k. but one exercise sent me back a syntax error.

My proposed code is: ¨
not True and not False != not False. I get error here.
Then I made it:
True and not False != False¨ and it worked.

I guess is because it cannot happen to be two not like in / not True and not False/
And that is my question? Is It my assumption correct? In case I am wrong I would like to ask kindly for the rightful explanation. Thanks for your attention. Best regards.


#2

the problem is in order which python handles comparison operator, != comes before not, while not False should be evaluated first so we can use parentheses to overcome this problem:

not True and not False != (not False)

#4

I must say, this is one of the most interesting comparison statements that I’ve seen recently. Because, it emphasizes the order of operations in Python.


#5

Thanks for your kindness.


#6

I do appreciate your help. Thank you so much.


#7