pacho_the_python

Courses

Mar 14th, 2022
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. data = input().split(" : ")
  2.  
  3. courses = {}
  4.  
  5. while True:
  6.     module = data[0]
  7.     if module == "end":
  8.         break
  9.     name = data[1]
  10.  
  11.     if module not in courses:
  12.         courses[module] = [name]
  13.     else:
  14.         courses[module] += [name]
  15.  
  16.     data = input().split(" : ")
  17.  
  18. for i in courses.keys():
  19.     print(f"{i}: {len(courses[i])}")
  20.     for y in courses[i]:
  21.         print(f"-- {y}")
  22.  
Advertisement
Add Comment
Please, Sign In to add comment