Something of Value: It says I keep getting the wrong total, but it think it's the right total


#1



The code printed 4 money totals instead of one conjoining total


My code(it says I get the wrong 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]
    
total = 0 

for keys in prices:
    print prices[keys] * stock[keys]
    
total= 0 + 45 + 48 + 24
print total


also how do I print the total price as a singular number instead of 4 numbers?


#2

by adding prices[keys] * stock[keys] to total


#3

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