info = [
{ "name": "John", "age": 28, "budget": 23000 },
{ "name": "Steve", "age": 32, "budget": 40000 },
{ "name": "Martin", "age": 16, "budget": 2700 }
]
def get_budgets(value: list) -> float:
"""
Takes a list of Dictionary of Employees
and returns the SUM of their budget
"""
return sum([item['budget'] for item in value])
print(get_budgets(info))
budget = [
{ “name”: “John”, “age”: 21, “budget”: 29000 },
{ “name”: “Steve”, “age”: 32, “budget”: 32000 },
{ “name”: “Martin”, “age”: 16, “budget”: 1600 }
]
def get_budgets(listDict):
sum = 0
for amount in listDict:
for k,v in amount.items():
if k == 'budget':
sum = sum + v
return sum