## Who won the surfing contest

In the previous chapter, you worked out the top three scores, but they're not much use without the names of the surfers that achieved those scores. There will no be surfing for you until you've finished the program.

Here's the code so far:

result_f = open("results.txt") for line in result_f:

(name, score) = line.split() scores.append(float(score)) result_f.close() scores.sort() scores.reverse() print("The top scores were:") print(scores[0]) print(scores[1]) print(scores[2])

You still don't know who won-

You still don't know who won-

/

Rewrite your current program to use two arrays: one to keep track of the scores, the other to keep track of the surfer names.

two arrays two arrays

You were to rewrite your current program to use two arrays: one to keep track of the scores, the other to keep track of the surfer names.

As well as the stores array) yow riee<^ a names array, "too- ~

result_f = open(llresultst*t") for line in result_f:

Append the surfer's name to the names array. sCores.append(float(sCore))

Remember b> sort the^

names array-

namesappend(name) result_fclose() scores.sort() sCoresreverse() names. sort() namesreverse()

print("The highest scores were:") print(names[0] + ' with ' + str(sCoresCOJ)) print(names[|] + ' with ' + str(sCores[|])) print(namesC23 + ' with ' + str(sCoresCZJ))