Joe HM3 83 HM2 39 HM4 90 HM1 85 Chris HM2 85 HM5 70 HM1 70 Doug HM1 80 HM3 94 HM2 93 HM4 75 Matt HM4 25 HM1 30 Ricardo HM3 80 HM1 90 Test1 90
I have to alphabetize the names and sort the grades by HM number from 1 to 4, ignoring all other grades. If they don't have a HM number then its a zero. I am stuck on sorting the grades from HM1 to HM4
readfile=open('studentgrades.txt','r')
readfile1_list=readfile.readlines()
NamesSorted_list=sorted(readfile1_list)
NumberOfNames_int=len(NamesSorted_list)
#for info in NamesSorted_list:
# names_str=info.split()[0]
# print names_str+' y'
# if 'HM3' not in NamesSorted_list[2].split():
# print 0
name1grades_list=[]
for hw_line in NamesSorted_list:
namegrade_list=hw_line.split()
for grades in namegrade_list:
print grades
Ive have tried googleing how sort grades by name.

New Topic/Question
Reply


MultiQuote



|