Advertisement
BdW44222

10. SoftUni Exam Results

Aug 13th, 2021
1,108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. students_info = input()
  2.  
  3. students_dict = {}
  4.  
  5. while not students_info == "exam finished":
  6.     username = students_info.split("-")[0]
  7.  
  8.     if students_info.split("-")[1] == "banned":
  9.         students_dict[None] = students_dict.pop(username)
  10.     else:
  11.       language = students_info.split("-")[1]
  12.       points = students_info.split("-")[2]
  13.  
  14.       if not username in students_dict:
  15.           students_dict[username] = {'language': language, 'points': []}
  16.  
  17.       if language in students_dict[username]['language']:
  18.           students_dict[username]['points'].append(points)
  19.       else:
  20.           students_dict[username]['points'].append(points)
  21.  
  22.     students_info = input()
  23.  
  24. for key, value in sorted(students_dict.items(), key=lambda x: (-x[1]['points'], x[1]['language'])):
  25.     if key:
  26.         print("Results:")
  27.         print(f"{key} | {value['points']}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement