So this is my list of dictionaries:
array_of_dictionaries = [{
"name": "Budi",
"age": 23,
"test_scores": [100.0, 98.0, 89.0]
},
{
"name": "Charlie",
"age": 24,
"test_scores": [90.0, 100.0]
}]
And this is my code:
def get_all_time_max_avg_score(dictionary_list):
for element in dictionary_list:
lensum = len(element['test_scores'])
elesum = sum(element['test_scores'])
meansum = elesum / lensum
for attribute in element.keys():
print("Mr. " + str(element['name']) + " with age(years) " + str(element['age']) + " get the highest average scores, " + str(round(meansum, 2)))
break
get_all_time_max_avg_score(array_of_dictionaries)
So I want to get the highest average scores from both of that dictionaries. The output I desired is:
Mr. Budi with age(years) 23 get the highest average scores, 95.67
But what I get is:
Mr. Budi with age(years) 23 get the highest average scores, 95.67
Mr. Charlie with age(years) 24 get the highest average scores, 95.0
I really appreciate every help I can get.