Thank you.... now it works prefectly. I inserted some extra stuff:
Score, Name, Times Played, Total time played.
I have now only one last question:
When i print this out, how do I make this look good? Now it prints out this:
(Total Score, Name, Times Played, Median Value, Total time played (sec))
(300, 'John')
(200, 'Jane')
(106, 'Bajs', 1, 106, 9)
(102, 'Hej', 1, 102, 9)
(83, 'test', 2, 41, 48)
(68.70051319954 6208, 'Testny', 1, 68, 14.555932021867 418)
(66, 'Runk', 1, 66, 15)
(58, 'test', 1, 58, 16)
(53, 'Test4', 1, 53, 18)
(I did'nt know how to wright it this way here, so i used the CODE-thing. I hope you understand what i mean)
This is the code i have:
Thanks
Score, Name, Times Played, Total time played.
I have now only one last question:
When i print this out, how do I make this look good? Now it prints out this:
(Total Score, Name, Times Played, Median Value, Total time played (sec))
(300, 'John')
(200, 'Jane')
(106, 'Bajs', 1, 106, 9)
(102, 'Hej', 1, 102, 9)
(83, 'test', 2, 41, 48)
(68.70051319954 6208, 'Testny', 1, 68, 14.555932021867 418)
(66, 'Runk', 1, 66, 15)
(58, 'test', 1, 58, 16)
(53, 'Test4', 1, 53, 18)
Code:
But i would like it to print out this way: (Total Score, Name, Times Played, Median Value, Total time played (sec)) (300 'John' 2 142 114) (200, 'Jane' 1 200 17) (106, 'Bajs', 1, 106, 9) (102, 'Hej', 1, 102, 9) (83, 'test', 2, 41, 48) (68. 'Testny', 1, 68, 14) (66, 'Runk', 1, 66, 15) (58, 'test', 1, 58, 16) (53, 'Test4', 1, 53, 18)
This is the code i have:
Code:
def highscore(totalscore, name, timesplayed, median, totaltime):
scores = open("scores", "r")
som blir en lista
hiscores = pickle.load(scores)
scores.close()
hiscores.append((totalscore, name, timesplayed, median, totaltime))
hiscores.sort
scores=open("scores", "w")
pickle.dump(hiscores[-10:], scores)
scores.close()
def highscore2():
scores = open("scores", "r")
oldscores = pickle.load(scores)
scores.close()
print "(Total Score, Name, Times Played, Median Value, Total time played (sec))"
for i in range(9, 0, -1):
print oldscores[i]
Comment