weight = {"pencil" : "10", "pen" : "20", "paper" : "4", "eraser" : "80" }
available = {"pen" : "3", "pencil" : "5", "eraser" : "2", "paper" : "10"}
overall_weight = 0
for key, value in weight.items():
if key in available:
overall_weight = weight.values() * available.values()
print (overall_weight)
print("Overall weight:", overall_weight)
CodePudding user response:
You need to cast the values to int. This should work:
weight = {"pencil" : "10", "pen" : "20", "paper" : "4", "eraser" : "80" }
available = {"pen" : "3", "pencil" : "5", "eraser" : "2", "paper" : "10"}
overall_weight = 0
for key, value in weight.items():
if key in available:
currA = int(value)
overall_weight = int(available[key]) * int(value)
print (overall_weight)
print("Overall weight:", overall_weight)