9.something of value


#1


9.Something of value

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


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]
    
ttotal = 0
for key in prices:
    value = prices[key] * stock[key]
    print key
    total += prices[key] * stock[key]
    total =+ value
print total


#2

This could all be done in the first loop.

total = 0
for key in prices:
    print key
    print "price: %s" % prices[key]
    print "stock: %s" % stock[key]
    total += prices[key] * stock[key]

print total

#3

Thank you!, i also noticed i wrote some lines multiply times and i accidentally wrote ttotal instead of total