1 == True | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

1 == True

So, for some reason, Python equates True and 1. So this code rewrites 1 from "apples" to False. This made testing the code incredibly confusing. Clearly whoever wrote the code didn't experiment with it or they would have realized they put up some incredibly confusing and misleading code. I hope this at least helps somebody.

19th Aug 2016, 2:08 AM
Taylor Street
Taylor Street - avatar
2 Answers
0
In Python 3.x True and False are keywords and will always be equal to 1 and 0.
19th Aug 2016, 6:43 AM
Andy Thieu
Andy Thieu - avatar
0
Right. I get that. Which is why it is a poor and confusing example. The example creates a dictionary value for 1, then it it overwrites it by creating a dictionary value for True. I doubt the designer intended to do that, because it is very confusing to a newcomer.
19th Aug 2016, 4:09 PM
Taylor Street
Taylor Street - avatar