Page 190 -
P. 190

hashes and databases


                        Code Magnets

                        Rearrange the code magnets at the bottom of the page to complete
                        the program shown below. Rather than using two arrays, this
                        program stores the results from the surfing contest in a hash:










                      result_f = open("results.txt")
                      for line in result_f:
                          (name, score) = line.split()



                      result_f.close()


                      print("The top scores were:")























                    scores[score] = name                  for each_score in scores.keys():




                 print('Surfer ' + scores[each_score] + ' scored ' + each_score)
                                                                                          scores = {}





                                                                                       you are here 4    155
   185   186   187   188   189   190   191   192   193   194   195