[Tutor] Python Programming for the Absolute Beginner - Chap 7 Q: 2

Adam Łuszcz adii0617 at gmail.com
Wed Mar 18 08:33:24 EDT 2020


Hey 

I've jus found your post about help in .py chellenge 2 chapter 7.  [below]
I got one qustion. Did you resolve that problem ? 
Please if its possible Could you sent me a solve that problem ? 

Thanks 

def high_score():

    """Records a player's score"""

 

    high_scores = []

 

    #add a score // Do current stuff for adding a new score...

    name = input("What is your name? ")

    player_score = int(input("What is your score? "))

    entry = (name, player_score)

    high_scores.append(entry)

    high_scores.sort(reverse=True)

    high_scores = high_scores[:5]       # keep only top five

 

    # dump scores

    f = open("pickles1.dat", "wb")

    pickle.dump(high_scores, f)

    f.close()

 

    f = open("pickles1.dat", "rb")

    high_scores = pickle.load(f)

    print(high_scores)

    f.close()

 

When I execute this program in the main() program I get only the existing
single name, player_score list combination stored in the pickles1.dat file.





More information about the Tutor mailing list