kostovhg

Courses

Aug 13th, 2021 (edited)
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. courses, nl, command = {}, '\n-- ', input()
  2. while True:
  3.     if command == "end":
  4.         break
  5.     course, student = command.split(" : ")
  6.     if course not in courses:
  7.         courses[course] = []
  8.     courses[course].append(student)
  9.     command = input()
  10. [print(f"{k}: {len(v)}\n-- {nl.join(sorted(v))}")
  11.  for k, v in {k: v for k, v in sorted(courses.items(), key=lambda x: -len(x[1]))}.items()]
Add Comment
Please, Sign In to add comment