George_Ivanov05

0.7

Jul 19th, 2021
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. string = input().split(" : ")
  2.  
  3. my_dict = {}
  4.  
  5. while string[0] != "end":
  6.     course = string[0]
  7.     name = string[1]
  8.     if course not in my_dict:
  9.         my_dict[course] = []
  10.         my_dict[course].append(name)
  11.     else:
  12.         my_dict[course].append(name)
  13.     string = input().split(" : ")
  14.  
  15. for key, value in sorted(my_dict.items(), key=lambda x: (len(x[1]), x[0]), reverse=True):
  16.     print(f"{key}: {len(value)}")
  17.     for i in value:
  18.         print(f"-- {i}")
Advertisement
Add Comment
Please, Sign In to add comment