I'm writing the following code to calculate consolidated grades of student to manage their Transcript, but not getting desired output, could someone help me in this,Thanx!
def transcript(coursedetails, studentdetails, grades):
studentdetails.sort()
coursedetails.sort()
grades.sort()
result=[(student,grade,coursedetail)
for student in studentdetails
for grade in grades for coursedetail in coursedetails
if((student[0]==grade[0])and(grade[1]==coursedetail[0]))]
print(result)
Input I'm giving is---
transcript([("MA101","Calculus"),("PH101","Mechanics"),("HU101","English")],[("UGM2018001","Rohit Grewal"),("UGP2018132","Neha Talwar")],[("UGM2018001","MA101","AB"),("UGP2018132","PH101","B"),("UGM2018001","PH101","B")])
Actual Output---
[(('UGM2018001', 'Rohit Grewal'), ('UGM2018001', 'MA101', 'AB'), ('MA101', 'Calculus')), (('UGM2018001', 'Rohit Grewal'), ('UGM2018001', 'PH101', 'B'), ('PH101', 'Mechanics')), (('UGP2018132', 'Neha Talwar'), ('UGP2018132', 'PH101', 'B'), ('PH101', 'Mechanics'))]
Desired Output---
[('UGM2018001', 'Rohit Grewal', [('MA101', 'Calculus', 'AB'), ('PH101', 'Mechanics', 'B')]), ('UGP2018132', 'Neha Talwar', [('PH101', 'Mechanics', 'B')])]