May 2017
Intermediate to advanced
310 pages
8h 5m
English
Dictionaries are arbitrary collections of objects indexed by numbers, strings, or other immutable objects. Dictionaries themselves are mutable; however, their index keys must be immutable. The following table contains all the dictionary methods and their descriptions:
|
Method |
Description |
|
len(d) |
Number of items in d. |
|
d.clear() |
Removes all items from d. |
|
d.copy() |
Makes a shallow copy of d. |
|
d.fromkeys(s [,value]) |
Returns a new dictionary with keys from sequence s and values set to value. |
|
d.get(k [,v]) |
Returns d[k] if found, or else returns v, or None if v is not given. |
|
d.items() |
Returns a sequence of key:value pairs in d. |
|
d.keys() |
Returns a sequence of keys in d. |
|
d.pop(k [,default]) ... |
Read now
Unlock full access