Computer Science
What type of objects can be used as keys in dictionaries ?
Python Dictionaries
15 Likes
Answer
Keys of a dictionary must be of immutable types such as
- a Python string
- a number
- a tuple (containing only immutable entries)
Answered By
8 Likes
Related Questions
State whether the following statement is True or False :
The fromkeys( ) creates a dictionary with given keys, each having a different value.
Why is a dictionary termed as an unordered collection of object?
Though tuples are immutable type, yet they cannot always be used as keys in a dictionary. What is the condition to use tuples as a key in a dictionary ?
What all types of values can you store in :
- dictionary-values ?
- dictionary-keys ?