0

Why do i get an error? (Access the Dictionary data-type by way of its native index)

dictionary = { "fimble" :4, "Jack" : 13, "umbrella": 10, "bottles": 2, "pn": "Tgursday 11May17", 3:464 } print(dictionary[3]) # You can still access the dictionary by it's native index print(dictionary[dictionary[3]])

14th May 2017, 3:58 PM
Laurence
3 Réponses
+ 6
print(dictionary [dictionary [3]]) print(dictionary[464]) #Value of key 3 is 464 error #Coz there is no such key 464
14th May 2017, 6:24 PM
Mr.Robot
Mr.Robot - avatar
+ 1
Dictionary are not like lists. You can not access it values using index, but using keys.
14th May 2017, 4:29 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
The first print works because there is a key that is 3 in the dictionary.
14th May 2017, 4:30 PM
Ulisses Cruz
Ulisses Cruz - avatar