Advertisement
horozov86

Courses

Mar 20th, 2023
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. dictionary = {}
  2.  
  3. while True:
  4.     line = input()
  5.     if line == "end":
  6.         break
  7.  
  8.     line_split = line.split(" : ")
  9.     course_name = line_split[0]
  10.     student_name = line_split[1]
  11.  
  12.     if course_name not in dictionary:
  13.         dictionary[course_name] = []
  14.     dictionary[course_name].append(student_name)
  15.  
  16. for course_name, students in dictionary.items():
  17.     print(f"{course_name}: {len(students)}")
  18.  
  19.     for student in students:
  20.         print(f"-- {student}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement