viligen

softuni_karaoke

Dec 1st, 2021
602
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. data_dict = {}
  2.  
  3. participants = input().split(", ")
  4. songs = input().split(", ")
  5.  
  6. while True:
  7.     data = input().split(", ")
  8.     if data[0] == "dawn":
  9.         break
  10.     participant, song, award = data
  11.     participant = participant.strip()
  12.     song = song.strip()
  13.     award = award.strip()
  14.  
  15.     if participant in participants and song in songs:
  16.         if participant not in data_dict:
  17.             data_dict[participant] = []
  18.         if award not in data_dict[participant]:
  19.             data_dict[participant].append(award)
  20. if not data_dict:
  21.     print("No awards")
  22. else:
  23.     sorted_data = sorted(data_dict.items(), key=lambda kvp: (-len(kvp[1]), kvp[0]))
  24.     for singer, awards in sorted_data:
  25.         print(f"{singer}: {len(awards)} awards")
  26.         print("\n".join(["--"+s for s in sorted(awards)]))
  27.  
  28.  
  29.  
RAW Paste Data