Page 168 -
P. 168

data in files and arrays




                                                Rewrite your program so that each time you read a new score you
                                                append it to the end of an array called scores.
                                                Then amend the code to print out the first 3 scores in the list.




                                    highest_score = 0
                 Here's the code as   result_f = open("results.txt")
                 it currently stands.
                                    for line in result_f:
                                        (name, score) = line.split()
                                        if float(score) > highest_score:
                                            highest_score = float(score)
                                    result_f.close()
                                    print("The highest score was:")
                                    print(highest_score)

                                                Hint: To create an empty array of scores use scores = [].








































                                                                                       you are here 4    133
   163   164   165   166   167   168   169   170   171   172   173