0

Write a program that has dictionary of names of five cricketers and a list of their runs in 5 matches. Create another dictionary

Write a program that has dictionary of names of five cricketers and a list of their runs in 5 matches. Create another dictionary from this dictionary that has name of the students and their total runs (sum of all runs). Find out the player with maximum number of runs def orangecap(match_details): players_data = {} for k, v in match_details.iteritems(): for player_name, score in v.iteritems(): prev_player = player_name if prev_player == player_name: score = players_data.get(player_name, 0) + score players_data[player_name] = score high_score_player = max(players_data, key=lambda i: players_data[i]) print (str(high_score_player), players_data[high_score_player]) can anyone tell how to create another dictionary from this dictionary that has name of students and their total runs?

31st Aug 2020, 8:29 AM
Muskan Singh
Muskan Singh - avatar
2 Respostas
+ 2
tot={player:sum(runs) for player, runs in crick_records.items() } edited
31st Aug 2020, 10:13 AM
Oma Falk
Oma Falk - avatar
0
~ swim ~ right... thanks!
31st Aug 2020, 10:28 AM
Oma Falk
Oma Falk - avatar