Someting of Value-help


I can't get to continue in the "something of value"

link to the exercise that I'm stuck at.

"Oops, try again. It looks like your code did not print the correct total."

I was expecting to get 'total' from my code. Don't understand why it is not printing it correctly. Please, any help or suggestions? Thanks, it is greatly appreciated.

for key in prices:
    value = (prices[key]*stock[key])
    total = 0
    total = total + value


this line:

total = 0

declaring total inside the loop means that total gets resetted to zero every time. So what you add tot toal, won't be accumalated. I would declare total before the loop

then print total outside/after the loop


That was it??:open_mouth:

Thanks a lot @stetim94 ! it worked. Hilarious!! :joy:


yea, that was it. But the difficulty is to find the problem and understand why its wrong, and how to fix it. I pretty much did all those steps for you now


Yeah, that's true. I didn't figure what was happened with "total". I totally got blinded in that part. Big confusion there. Thanks once again