Merhaba coderlar, pythonda codeacademy kasıyorum ama takıldım, codumuz şöyle

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]



bizden istediği de şu : Create a variable called total and set it to zero.
Loop through the prices dictionaries.
For each key in prices, multiply the number in prices by the number in stock. Print that value into the console and then add it to total.
Finally, outside your loop, print total.


yani dıyorki stock*price i print et totale ekle dıyor.

Any help is appreciated.

 

print "price: %s" % prices[key]
kodundan sonra

total += prices[key]
koy.

en alta da fordan çıktıntan sonra print total de.

eksi sozlukte eksiyen adam

sen de yazdığını postla da onun üzerinden gidelim. Bir de codecademy bazen sapıtıyor. virgüllere boşluklara falan dikkat et sayfayı yenile.

safepassage

eksi sozlukte eksiyen adam. olmadı o kod. bizden istediği stocktaki urunlerın toplam değeri

total = 0
total += prices[key]*stock[key]
print total


denedim olmadı bu arada

anonymice

en üstte total = 0 yapman lazım.

yoksa her for'da 0 yapar total'i.

prices[key]*stock[key] olması lazım.

codepaste.net

yukarıda verdiğim şekilde çalışıyor.

eksi sozlukte eksiyen adam

tesekkurler dostum, çözüldü.

anonymice
1

mobil görünümden çık