Something of value - help


#1




i don't know how to add all total together


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]

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


#2

Hellooo anybody here?


#3

here:

 for key in prices:

why is there indent before for? it is in indentionerror, or went this wrong when copying to the forum?

as for your total, in each iteration of the loop total gets (re)set to zero

declare total before the loop

also, you should add the prices * stock to total, one equal sign will set total to prices * stock not increase total by prices * stock.

It is a forum, the response might take some time


#4

Thanks.. figured out the mistake


#5