[Tutor] Strange results when using not operation.
Mats Wichmann
mats at wichmann.us
Fri Apr 21 14:02:37 EDT 2023
On 4/21/23 08:26, Magnus Myrefors via Tutor wrote:
> Hello !
>
> I am currently Reading a ”Beginning Python” book, and when I did some tests with the not operation in the IDLE python Shell I saw som strange results. When I typed ’ not”A” == False ’ the result was ’True’ and when I typed ’ not”A” == True ’ the result was ’True’ again. I got similar results when I typed ’ not(2) == False ’ and ’ not(2) == True ’ which both gave the result ’True’ . When I put the whole left side in paranthesis like this: ’ (not”A”) == False’ and ’ (not”A”) == True ’ the results were different.
>
> Magnus
>
> Skickades från E-post för Windows
You're negating an expression.
>>> "A" == False
False
>>> not "A" == False
True
More information about the Tutor
mailing list