Code Written In Python
# Following Are The 3 Lists
sections = ['A', 'B', 'A', 'A', 'B']
students = ['Jack', 'Jim', 'Jack', 'Leena', 'Jim']
subjects = ['Maths', 'Biology', 'Chemistry', 'English', 'Physics']
# The Output Should Be A Dictionary
classDict = {'A':{'Jack' :{1:'Maths', 2:'Chemistry'}, 'Leena':{1:'English'}}, 'B':{'Jim':{1:'Biology', 2:'Physics'}}}
I can merge any of the two list into one dictionary, taking only first two lists in account
classDict = {}
for stu in students:
if not stu in classDict:
classDict[stu] = []
classDict[stu].append(stu)
But unable to extend it to n(n=3, in my case) list.
defualtdict and zip are your friends for this one:
I believe the following would work.
you could even do this in one line if you really wanted to.