1 == True | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
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