Hash Brownies
We'll cover the following...
Let’s learn about the peculiar nature of Python dictionaries.
Press + to interact
some_dict = {}some_dict[5.5] = "JavaScript"some_dict[5.0] = "Ruby"some_dict[5] = "Python"print(some_dict[5.5])print(some_dict[5.0]) # "Python" destroyed the existence of "Ruby"?print(some_dict[5])print("---------")complex_five = 5 + 0jprint(type(complex_five))print(some_dict[complex_five])
So, why is Python all over the place?
Explanation
- Uniqueness of keys in a Python dictionary is by equivalence, not identity. So even though
5
,5.0
,