Page 183 -
P. 183
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 scores scores = []
array, you now need
a names array, too. names = []
result_f = open(“results.txt")
for line in result_f:
(name, score) = line.split()
Append the surfer's name
to the names array. scores.append(float(score))
names.append(name)
result_f.close()
scores.sort()
scores.reverse()
Remember to sort the names.sort()
names array.
names.reverse()
print(“The highest scores were:")
print(names[0] + ‘ with ' + str(scores[0]))
print(names[1] + ‘ with ' + str(scores[1]))
print(names[2] + ‘ with ' + str(scores[2]))
Load this!
Don't forget to download results.
txt from the Head First Programming
website before continuing.
148 Chapter 5