I realize this is a fairly generic type of question, but being new to programming, I'm not sure how best to approach it.<div><br></div><div>I'm doing a tutorial and was given a problem, using shelve. It's taking a user name and then asking for scores in a game, until you end the loop. Whatever score is the high score, should be returned from the function:</div>
<div><br></div><div>Here is what I have so far:</div><div><br></div><div>import shelve</div><div><br></div><div>def user_scores():<br></div><div> user_name = input ("What is the user name?").rstrip()</div><div>
scores = int(input("What is the users score, enter 0 if done"))</div><div> shelf = shelve.open('scores.py', writeback=True)</div><div> score = [scores]</div><div> user = {user_name:score}</div><div>
shelf['user'] = user</div><div> shelf.close()</div><div> while scores > 0:</div><div> scores = int (input("What is the next score"))</div><div> shelf = shelve.open('scores.py', writeback=True)</div>
<div> score.append(scores)</div><div> shelf['score'] = score</div><div> shelf.sync()</div><div> shelf.close()</div><div><br></div><div>What I'm not sure of is how to compare the values of score, to find and print the one that is highest. Any suggestions? </div>
<div><br></div><div>Becky </div><div> </div><div><br></div>