Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- courses = {}
- while True:
- txt = input()
- if txt == 'end':
- break
- txt = txt.split(' : ')
- if txt[0] not in courses.keys():
- courses.update({txt[0]: [1, [txt[1]]]})
- else:
- l = []
- l.append(txt[1])
- courses.update({txt[0]: [courses[txt[0]][0] + 1, courses[txt[0]][1] + l]})
- for k, v in sorted(courses.items(), key=lambda i: -(i[1][0])):
- print(f'{k}: {v[0]}')
- for i in sorted(v[1], reverse=False):
- print(f'-- {i}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement