At a loss on this. I'm getting a key error but I can't figure out why as the key referenced looks like it's in the dict.
Any help?
TEMPLATE = "{ticker:6s}:{shares:3d} x {price:8.2f} = {value:8.2f}"
report = []
stock = {'ticker': 'AAPL', 'price': 128.75, 'value': 2575.0, 'shares': 20}
report.append(TEMPLATE.format(stock))
This is the error I got:
report.append(TEMPLATE.format(stock))
KeyError: 'ticker'