I am getting error ..list out of range with this code.. can someone help pls?
def classGrade(infile):
inf=open(infile)
contents=inf.readlines()
inf.close()
classg={}
for line in contents:
y=line.split("\t")
d={}
print(y)
d['id']=y[0]
d['exam1']=y[1]
d['exam2']=y[2]
d['homework']=y[3]
d['attendance']=y[4]
d['project']=y[5]
d['classrecap']=y[6]
classg[y[0]]=d
print(classg)
print (classGrade('mock1.txt'))
mock1.txt
is bad. – hyades 36 mins agoprint(y)
after the split. Bet there's a blank line. – kindall 32 mins agomock1.txt
. If possible, you may show a sample of its contents to us (by adding it to your question post). – Ébe Isaac 32 mins ago\t
) -- Are you sure that those are tabs and not spaces? (Your text editor may use spaces for the tab key) – sytech 17 mins ago