[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Game not running



Well i used the pickle module.. Like this!
def highscore(s):
    with open('highscore.pkl', 'r+b') as f:
        score = pickle.load(f)
    
    for i in range(len(score)):
        if s > score[i-1]:
            score[len(score)-1] = s
            break
    score.sort()
    score.reverse()
    with open('highscore.pkl', 'w+b') as f:
        pickle.dump(score, f, pickle.HIGHEST_PROTOCOL)

Thanks everyone!