Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string = input().split(" : ")
- my_dict = {}
- while string[0] != "end":
- course = string[0]
- name = string[1]
- if course not in my_dict:
- my_dict[course] = []
- my_dict[course].append(name)
- else:
- my_dict[course].append(name)
- string = input().split(" : ")
- for key, value in sorted(my_dict.items(), key=lambda x: (len(x[1]), x[0]), reverse=True):
- print(f"{key}: {len(value)}")
- for i in value:
- print(f"-- {i}")
Advertisement
Add Comment
Please, Sign In to add comment