Advertisement
Spocoman

02. SoftUni Karaoke

Feb 15th, 2024
1,140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. participants = input().split(', ')
  2. songs = input().split(', ')
  3. info = {}
  4.  
  5. while True:
  6.     command = input()
  7.     if command == 'dawn':
  8.         break
  9.  
  10.     participant, song, award = command.split(', ')
  11.  
  12.     if participant in participants and song in songs:
  13.         if participant not in info.keys():
  14.             info[participant] = [award]
  15.         if award not in info[participant]:
  16.             info[participant].append(award)
  17.  
  18. if len(info) > 0:
  19.     for key in sorted(info, key=lambda k: len(info[k]), reverse=True):
  20.         print(f'{key}: {len(info[key])} awards')
  21.         for value in sorted(info[key]):
  22.             print(f'--{value}')
  23. else:
  24.     print('No awards')
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement