Computer Science
How is indexing of a dictionary different from that of a list or a string?
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.
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?
What values can we have in a dictionary?
Can you change an element of a sequence or collection? What if a collection is a dictionary? What if a sequence is a string?