Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def process_data():
- courses_n_students = {}
- while True:
- command = input()
- if command == "end":
- return courses_n_students
- course, student = command.split(" : ")
- if course not in courses_n_students.keys():
- courses_n_students[course] = []
- courses_n_students[course].append(student)
- def print_data(courses_data):
- ordered_dictionary = dict(sorted(courses_data.items(), key=lambda x: x[0]))
- for course_name in ordered_dictionary.keys():
- people_on_course = len(ordered_dictionary[course_name])
- print(f"{course_name}: {people_on_course}")
- for student in ordered_dictionary[course_name]:
- print(f"-- {student}")
- courses = process_data()
- print_data(courses)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement