Question: Write a python function roster_map(c) that takes in such a dictionary and returns a new dictionary that maps the name of each course to a

Write a python function roster_map(c) that takes in such a dictionary and returns a new dictionary that maps the name of each course to a set of students taking that course.

The dictionary maps a students name to a comma-separated string of courses that the student is taking

Test Cases

Test1

c0 = {"john": "cs1,psych101", "jade": "calc3,cs2,bio5", "annie": "cs1,bio5"} output0 = {'calc3': {"jade"}, 'cs1': {"annie", "john"}, 'bio5': {"jaade", "annie"}, 'psych101': {"john"}, 'cs2': {"jade"}} assert(roster_map(c0) == output0)

Test2

c1 = {"john": "math1", "jade": "physics2,math1", "annie": "chem3,math1", "may": "math1"} output1 = {'math1': {'john', 'jade', 'annie', 'may'},'physics2': {'jade'}, 'chem3': {'annie'}} assert(roster_map(c1) == output1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!