Computer Science
Which of the following types qualify to be the keys of a dictionary?
- String
- tuple
- Integer
- float
- list
- dictionary
Python Dictionaries
2 Likes
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
How are individual elements of dictionaries accessed?
How is indexing of a dictionary different from that of a list or a string?
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.