Error


#1

My code is saying return outside of function on line 24. Why?
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 item in prices:
total = 0
print prices[item] * stock[item]
return total

print total


#2

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 item in prices:
total = 0
print prices[item] * stock[item]

print total

This is the new problem:It's not printing the correct total.


#3

*) on second for loop use the same key to loop through prices
*) and store price * stock in new variable say count
*) then total the count say total += count
*) finally print the total