9/13 I really don´t know what to do ^^'


#1

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]
print

total = 0
for key in prices:
print prices[key] * stock(key):
total = total + prices{key} * prices{stock}

print total

I think the line after the last for-loop is incorrect but I really don´t know how to solve it.
I think I´m to focused and maybe it´s an easy task I just don´t understand...
Please Help me Grand-Masters-of-the-Internet !


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

This is the code I used and it worked. I think your syntax is wrong and don't forget to indent after using the for loop.


#3

Does anyone know why Python would understand that 'key' can be applicable in both the prices and stock dictionaries, but only defined in one for loop (which takes in prices)?