Advertisement
kostovhg

courses of Yordanov

Aug 13th, 2021
1,339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. courses = {}
  2. while True:
  3.     txt = input()
  4.     if txt == 'end':
  5.         break
  6.     txt = txt.split(' : ')
  7.     if txt[0] not in courses.keys():
  8.         courses.update({txt[0]: [1, [txt[1]]]})
  9.     else:
  10.         l = []
  11.         l.append(txt[1])
  12.         courses.update({txt[0]: [courses[txt[0]][0] + 1, courses[txt[0]][1] + l]})
  13.  
  14. for k, v in sorted(courses.items(), key=lambda i: -(i[1][0])):
  15.     print(f'{k}: {v[0]}')
  16.     for i in sorted(v[1], reverse=False):
  17.         print(f'-- {i}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement