HELP! Hi I'm a newbie in Python, I'm having trouble organizing the FILE into the OUTPUT BELOW. I put the file into read, then I put it on a list, and my plan is to put the name and the corresponding grades into a dictionary, using the elements on the list, but when I print the dictionary, it's not giving me the result I wanted. MY CODE SO FAR IS SHOWN BELOW THE OUTPUT. For more details of the assignment, go to this link http://ranger.uta.edu/~kamangar/Courses/CSE_1310_FA12/Homework5(DueDate.Oct.16,2012).html#Topic18 Thank you so much.
FILE HM3, 80 , HM2 ,90 , ID, 1000123456,HM4,92,Last_name,Rubble ID, 1000100200,Last_name,Bunny,HM2,92,HM5,70,HM1,98, ID, 1000123300,HM1,86, HM3,100,Last_name,Duck HM4,96,Last_name,Chipmunk,HM1,86,ID,1000456456 Last_name,Simpson,HM3,70, HM1, 90 ,ID, 1000321321,Test1,90 HM1,87,Last_name,Duck,HM2, 100 ,HM4,94,ID, 1000123300 HM3,95,HM2,88,Last_name, Chipmunk ,HM1,86 , ID,1000999888 HM1, 92 ,Last_name,Simpson,ID, 1000321321,HM2,90 OUTPUT Name | ID | HM1 | HM2 | HM3 | HM4 | Avg. | ___________________________________________________________________ Bunny | 1000100200 | 98 | 92 | 0 | 0 | 47.50 | Chipmunk | 1000456456 | 86 | 0 | 0 | 96 | 45.50 | Chipmunk | 1000999888 | 86 | 88 | 95 | 0 | 67.25 | Duck | 1000123300 | 87 | 100 | 100 | 94 | 95.25 | Rubble | 1000123456 | 0 | 90 | 80 | 92 | 65.50 | Simpson | 1000321321 | 92 | 90 | 70 | 0 | 63.00 | THIS IS MY CODE SO FAR filename = open("student_grades_hm_5.txt") infile = filename.read() mix_list = infile.split() print "Name | ID | HM1 | HM2 | HM3 | HM4 | Avg. |" print "______________________________________________________" Student_one = {"Name":mix_list[9],"ID":mix_list[5],"HM1":0,"HM2":mix_list[3], "HM3":mix_list[1],"HM4":mix_list[7]} print Student_one
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor