Dictionaries: Accessing items
Syntax: list[key]
- E.g.
>>> d = {'item':'tire','price':20.99}
>>> d[‘price']
20.99
>>> d[item]
Traceback (most recent call last):
File "", line 1, in ?
d[item]
NameError: name 'item' is not defined
>>> str = 'item'
>>> d[str]
'tire'