[Solved] Python Key Error:1
[ad_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: … Read more