Computer Science
Which of the following types qualify to be the keys of a dictionary?
- String
- tuple
- Integer
- float
- list
- dictionary
Python Dictionaries
CBSE
1 Like
Answer
The following types can be used as keys of a dictionary because they are immutable:
- String
- tuple
- Integer
- float
As lists and dictionaries are mutable so they cannot be used as keys of a dictionary.
Answered By
1 Like
Related Questions
Can you change an element of a sequence or collection? What if a collection is a dictionary? What if a sequence is a string?
What do you understand by ordered collection and unordered collection ? Give examples.
How is indexing of a dictionary different from that of a list or a string?
How are individual elements of dictionaries accessed?