Dictionary
suggest changeSyntax
mydict = {}mydict[k] = valuevalue = mydict[k]value = mydict.get(k)value = mydict.get(k, “default_value”)
Parameters
key| The desired key to lookupvalue| The value to set or return
Remarks
Helpful items to remember when creating a dictionary:
- Every key must be unique (otherwise it will be overridden)
- Every key must be hashable (can use the
hashfunction to hash it; otherwiseTypeErrorwill be thrown) - There is no particular order for the keys.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents