When i do the add_player statement, it doesn't want to edit the current ppp.txt file. When i list the players currently in the ppp.txt file its seems ok, its just adding a new player doesnt seem to work.
Thanks is advance for your help, its much appreciated.
Code:
players=open("ppp.txt","r")
lis=[]
for line in players:
line=line.strip()
x=line.split(";")
p=Person()
p.surname=x[0]
p.forename=x[1]
p.email=x[2]
p.phonenum=x[3]
p.current_div=x[4]
p.current_points=x[5]
p.prev_div=x[6]
p.prev_points=x[7]
lis.append(p)
for p in lis:
print "%6s%12s%25s%14s%10s%10s%18s%15s"%(p.surname,p.forename,p.email,p.phonenum,p.current_div,p.current_points,
p.prev_div,p.prev_points)
players.close()
def add_player(surname,forename,email,phone_num,current_div,current_points,prev_div,prev_points):
'''
This function allows the user to add another player to the text file
surname=surname of player
forename=forename of the player
email=email of player
phonenum=phonenum of player
current_div= the current division for the player
current_points=current points of the player
prev_div=the previous division of the palyer
prev_points=the previous points of the player
'''
lis.append([surname,forename,email,phone_num,current_div,current_points,prev_div,prev_points])
add_player("j","k","L","1","2","3","4","5")
Comment