I would love for somone to help me with this problem in the python course


#1

It keeps saying the same error and I don´t understand what it means

prices = {
"banana" : 4,
"apple" : 2,
"orange" : 1.5,
"pear" : 3,
}
stock = {
"banana" : 6,
"apple" : 0,
"orange" : 32,
"pear" : 15,
}
for key in prices:
total = 0
print prices[key] * stock[key]
total prices[key] * stock[key]
print total = total +


#2

any suggestions will be very appreciated.


#3

Hi
below you can find my code, which worked for me.

prices = {
"banana" : 4,
"apple" : 2,
"orange" : 1.5,
"pear" : 3,
}
stock = {
"banana" : 6,
"apple" : 0,
"orange" : 32,
"pear" : 15,
}

for key in prices:
    print key
    print "price: %s" % prices[key]
    print "stock: %s" % stock[key]

total = 0    
for key in prices:
    total = prices[key] * stock[key] + total
    print prices[key] * stock[key]
    

print total

About your code, I am not an expert, but I think total = 0 should be outside for loop. Also, there is = mark missing between total and prices[key] * stock[key]. What's more, total=total+ didn't worked for me.