+ 3
Do dictionaries call from 1 or 0 like list?
Dictionaries and lists.
3 Antworten
+ 5
You don't access to dictionnary values via an index number like with lists. Instead, you use the key to the value.
ages = {"Dave": 24, "Mary": 42, "John": 58}
print(ages["Dave"])
+ 1
Internally but not normally (so: no). It's because they're unordered (by design) and you can 'emulate' the feature by using numeric keys.
Abnormally: Trying to get at the 'real' index is potentially confusing, probably neither portable nor repeatable and may surprise others unless you're debugging/testing python (the package) itself.
0
no you can not access dictionary values using 1,2 like list.
it can be accessed through keys.