Why do I keep getting this error?- Something of Value



Traceback (most recent call last):
File "python", line 20, in
KeyError: 1

Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: 1

I don't know.

Replace this line with your code. 
total = 0
for i in prices: 
    total = total + (prices[1]*stock[1])


This is supposed to be for each key in prices, so instead of 1, it should be i in your total equation.

total = total + prices[i] * stock[i]


Thank you! I guess I thought 1 was i for some weird reason!


You're welcome. :slight_smile:


do u actually work for codecademy, btw?


Nope, very few people on the Forum actually work for Codecademy. :slight_smile:


another code able like this:

for mk in prices:
    print mlt
print total


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.