[Solved] Python Key Error:1


I think you are confusing lists with dicts.

The keys of your items dict are ‘coke’, ‘mars’, ‘fanta’, etc. and that is how you access it like items['coke'].

To iterate the items, something like this is more usual:

>>> def list_items():
...     for k,v in items.items():
...         print("{}: {}".format(k, v))
...         
>>> list_items()
coke: 1.50
mars: 1.00
galaxy: 2.00
wispa: 1.50
fanta: 1.40

1

solved Python Key Error:1