[Tutor] Behavior of dictionary in mapping keys that evaluate equal

khalil zakaria Zemmoura zemmoura.khalil at gmail.com
Wed May 11 09:00:47 EDT 2016


Hi,

Suppose we have a dict
Dic = { True: 'yes', 1: 'No'}

According to the Python 3 documentation, the keys must have a unique value
so True is converted to integer because of the type coercion (boolean are
subtype of integer) so boolean are winded to integer to be compared.

Am I missing something?

If that's what happen, why when running Dic.items() it return [(True,
'No')] instead of [(1, 'No')]


More information about the Tutor mailing list