0
How to sum of inner values of a each key in dictionary
d={ "BMW":{"black":5, "white":2}, "Benz":{"black":2, "blue":1}} how to sum of cars and output be: BMW: 7 Benz: 3
2 odpowiedzi
+ 3
Something like this:
for k,v in d.items():
print k + ': ' + str(sum(v.values()))
0
thank you