[Tutor] Strange results when using not operation.

dn PythonList at DancesWithMice.info
Fri Apr 21 15:39:29 EDT 2023


Hello!

On 22/04/2023 02.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.

To my old eyes, the code seems to run together, eg it should be:

not "A"

(with a space between)

The keyword "not" is a separate "token" from the string!


To avoid confusion, please copy-paste code (and responses) from the IDLE 
editor into separate lines of the email-message.

-- 
Regards,
=dn


More information about the Tutor mailing list