why is my high score list code not working?
Programming in Python, Michael Dawson, Chapter 7, Task 2. The book has already given the code for the game Quiz. We need to improve the game and add a list of records. The game code consists of functions. Below is my highscore list code. I added it to the main function of the game. The game results were not saved. The code displayed -0. How to solve it? And I also wanted to make the highscore list code as a function and then call this function in the main function. But I don’t know how to do it. If anyone knows please help. high_scores = [] try: f = open("high_scores.dat", "rb") high_scores = pickle.load(f) except: high_score = 0 high_scores.append((name, scores)) high_scores = sorted(high_scores, key=itemgetter(1), reverse=True)[:3] print(f"Рекорд: {high_scores[0][0]} - {high_scores[0][1]}") f.close() f = open("high_scores.dat", "wb") pickle.dump(high_scores, f) f.close()