In a program, a dictionary contains lists of students and their courses. The teacher is interested to
Question:
In a program, a dictionary contains lists of students and their courses. The teacher is interested to have a dictionary that has the courses as key and the students enrolled in each course as values. Each key has three different values.
To address this requirement, create a function to invert the dictionary and implement a solution that satisfies the teacher's need. In particular, the function will need to turn each of the list items into separate keys in the inverted dictionary.
Sample input:
{
'Stud1: ['CS1101', 'CS2402', 'CS2001'],
'Stud2: ['CS2402','CS2001','CS1102']
}
Inverted Output:
{
'CS1101': ['Stud1'],
'CS2402':['Stud1','Stud2'],
'CS2001': ['Stud1','Stud2']
'CS 1102'['Stud2']
}
Programming Instructions:
- Print the original dictionary as well as the inverted dictionary.
- Include your the Python program and the output in your submission.
- The code and its output must be explained technically. The explanation can be provided before or after the code, or in the form of comments within the code.
Statistics The Art And Science Of Learning From Data
ISBN: 9780321755940
3rd Edition
Authors: Alan Agresti, Christine A. Franklin