Computer Science
How is indexing of a dictionary different from that of a list or a string?
Python Dictionaries
CBSE
6 Likes
Answer
In lists or strings, the elements are accessed through their index where as in dictionaries, the elements are accessed through the keys defined in the key:value pairs. Moreover, lists and strings are ordered set of elements but dictionaries are unordered set of elements so its elements cannot be accessed as per specific order.
Answered By
4 Likes
Related Questions
Which of the following types qualify to be the keys of a dictionary?
- String
- tuple
- Integer
- float
- list
- dictionary
How are individual elements of dictionaries accessed?
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 values can we have in a dictionary?