After starting my coursework I've come across the following error code... "List index out of range". I was expecting this to be something very simple that I've done wrong and still imagine it will be seeing as I've written code similar to this before.
The code is designed to turn a list of players/members into separate strings. The code is shown below...
A sample of the players.txt file is...
A;Ed;Young;e.yo ung@lboro.ac.uk ;223376;1;0;1;0
B;Gordon;McTagg art-Cowan;g.b.mctag gart@lboro.ac.u k;226276;1;0;1; 0
C;Tom;Kane;t.g. kane@lboro.ac.u k;726653;1;0;1; 0
D;Chris;Holmes; c.r.holmes@lbor o.ac.uk;225378; 1;0;1;0
E;David;Mulvane y;d.k.mulvaney@ lboro.ac.uk;227 142;1;0;1;0
F;James;Buller; j.buller@lboro. ac.uk;223543;1; 0;1;0
A;Andrew;Wright ;a.wright@lboro .ac.uk;218432;2 ;0;2;0
If someone's able to shed a bit of light on why I'm getting this error code I'll be thankful as I'm not back at university until Monday.
The code is designed to turn a list of players/members into separate strings. The code is shown below...
Code:
class Member(object):
'''a member'''
fin = open ("players.txt","r")
l= []
for line in fin:
line=line.strip()
x = line.split(";")
memb = Member()
memb.id= x[0]
memb.forename= x[1]
memb.surname= x[2]
memb.email= x[3]
memb.phone= x[4]
memb.divc= x[5]
memb.pointc= x[6]
memb.divp= x[7]
memb.pointp= x[8]
l.append(memb)
fin. close ()
print l
A;Ed;Young;e.yo ung@lboro.ac.uk ;223376;1;0;1;0
B;Gordon;McTagg art-Cowan;g.b.mctag gart@lboro.ac.u k;226276;1;0;1; 0
C;Tom;Kane;t.g. kane@lboro.ac.u k;726653;1;0;1; 0
D;Chris;Holmes; c.r.holmes@lbor o.ac.uk;225378; 1;0;1;0
E;David;Mulvane y;d.k.mulvaney@ lboro.ac.uk;227 142;1;0;1;0
F;James;Buller; j.buller@lboro. ac.uk;223543;1; 0;1;0
A;Andrew;Wright ;a.wright@lboro .ac.uk;218432;2 ;0;2;0
If someone's able to shed a bit of light on why I'm getting this error code I'll be thankful as I'm not back at university until Monday.
Comment