Advertisement
angelstoev

Untitled

Nov 7th, 2022
1,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. courses = {}
  2. while True:
  3.     command = input().split(" : ")
  4.     course_name = command[0]
  5.     if course_name == 'end':
  6.         break
  7.     student_name = command[1]
  8.     if course_name not in courses.keys():
  9.         courses[course_name] = [student_name]
  10.     else:
  11.         courses[course_name] += [student_name]
  12. for course_name, registered_students in courses.items():
  13.     print(f"{course_name}: {len(registered_students)}")
  14.     print(f'-- {" ".join(courses[course_name])}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement