Syntax
- mydict = {}
- mydict[k] = value
- value = mydict[k]
- value = mydict.get(k)
- value = mydict.get(k, "default_value")
Parameters
| Parameter | Details |
|---|
| key | The desired key to lookup |
| value | The value to set or return |
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
hash function to hash it; otherwise TypeError will be thrown)
- There is no particular order for the keys.