Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data_dict = {}
- participants = input().split(", ")
- songs = input().split(", ")
- while True:
- data = input().split(", ")
- if data[0] == "dawn":
- break
- participant, song, award = data
- participant = participant.strip()
- song = song.strip()
- award = award.strip()
- if participant in participants and song in songs:
- if participant not in data_dict:
- data_dict[participant] = []
- if award not in data_dict[participant]:
- data_dict[participant].append(award)
- if not data_dict:
- print("No awards")
- else:
- sorted_data = sorted(data_dict.items(), key=lambda kvp: (-len(kvp[1]), kvp[0]))
- for singer, awards in sorted_data:
- print(f"{singer}: {len(awards)} awards")
- print("\n".join(["--"+s for s in sorted(awards)]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement