index
mutable, dictionary can be modified.
Dicitonary is a collection of key value pairs, for example: {βaβ:1,βbβ:2,βcβ:3}
Dicitonary keys is a sequence, iterable
d={βaβ:1,βbβ:2,βcβ:3}
for i in d.keys():
print\(i\)d[βaβ] is 1, d[βbβ] is 2, d[βcβ] is 3
Convert to List, use function dict()
d=dict(a=1,b=2,c=3)
Above is the same as
d={βaβ:1,βbβ:2,βcβ:3}
Dictionary is an object, meaning it has methods and attributes that can be invoked
To see all methods, type
help(<dictionary variable>)
In Jupyter notebook, to see list of methods or attributes
Press shift key after enter <tuple variable>.
Last updated