Given list of dicts with "name","runs","team", return top k teams by total runs descending.
Implement this function:
def top_k_teams(batsmen: list, k: int) -> list:
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: batsmen, k.
Input
[{'name': 'A', 'runs': 50, 'team': 'X'}, {'name': 'B', 'runs': 30, 'team': 'Y'}, {'name': 'C', 'runs': 20, 'team': 'X'}]
2
Output
['X', 'Y']