A day at the supermarket ,something of value exrcse

#1

My code seems to be working ( ihave uploaded the screen shot), but I keep getting this error

can someone please confirm if there is a bug? or is my code wrong?-Thanks!

#2

you just have to multiply the number in `prices` by the number in `stock`.

inside the loop at each iteration you are changing the value of key what you are not told.

for checking print at last line

`print prices['orange']`

so just multiply the number in `prices` by the number in `stock`.

`prices[key]*stock[key]`

print the value and just add this to `total`

#3

Thank you very much . I tried what you suggested and it worked. I am slightly confused as my code too gave the correct answer (117). I was also printing out the total cost of each item multiplied by its stock. I added these subtotal and got th3 correct answer. After I modified the code as you suggested and made got the exercise to pass ,I Reverted to the old code.To my surprise this time it passed and the error message was absent

#4

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