In the following program I have a few questions.
results.txt
Johnny 8.65
Juan 9.12
Joseph 8.45
Stacey 7.81
Aideen 8.05
Zack 7.21
Aaron 8.31
scores = {}
result_f = open("results.txt")
for line in result_f:
(name, score) = line.split()
scores[score] = name
result_f.close()
print("The toop scores were:")
for each_score in sorted(scores.keys(), reverse = True):
print("Surfer " + scores[each_score] + " scored " + each_score)
(name, score) = line.split()
scores[score] = name
Why is the value "name" being placed into the variable [score]? It looks to me like it's just swapping places with name and score.
Secondly, what is reverse = Ture? Is reverse a function, because it doesn't look like one. It looks to me like a simple statement inside of the sorted function and after the keys function.
Last but not least, when I run my program, it doesn't display the score Juan 9.12.
Thanks for any and all response.