Question: Write a Python function to read players' names and scores from a file into two parallel lists, a list of names and a list

Write a Python function to read players' names and scores from a

Write a Python function to read players' names and scores from a file into two parallel lists, a list of names and a list of scores, which will be used during the game. While reading the file, your function keeps track of the best score read so far, along with the name of the player who got that score. After reading all of the names and scores, your function displays the highest score and that player's name. For instance, if Karin had the best score and her score was 5970, your function would display: Karin has the best score: 7212 Here's an example file: Michael 4999 Chris 5970 Madeleine 4110 Karin 7212 Strip off the newline character before adding a name to the list of names. Assume that the filename is given when the function is called, so do not ask the user for a filename. Also, assume that the two lists are initially empty and that all scores are different: there are no ties. Here is the header line for the function: def readFile(fileName, nameList, scoreList): ****** Opens and reads fileName into two parallel lists: nameList and scoreList. Also, determines and displays the highest score, and that player's name Assumes file is in correct format: name, score, name, with each name and each score on a separate line in the file Assumes that nameList and scoreList are initially empty Assumes that all scores are different: there are no ties * * * ***

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

def readscoresfilename Initialize empty lists to store names and scores names score... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!