Here’s the bit of code I wrote for this particular segment of the Python course. I’m rather happy with its simplicity:
# Two dictionaries given: {prices} and {stock}
total = 0
for item in prices:
worth = prices[item] * stock[item]
total += worth
print total