6. What are the names of the winners?¶
6.1. Using another list¶
We can use two lists to find out.
The
namesandscoreslists to save the names and scores obtained by the participants respectively.
Data file:
surf4_en.txtJohny 8.65 Juan 9.12 Joseph 8.45 Stacey 7.81 Aideen 8.05 Zack 7.21 Aaron 8.31
6.2. But these data are incorrect!¶
There must be a problem because Zack is really bad!
What happened?
By sorting the
nameslist in decreasing order, the character'Z'ends up being the first.The correspondence between scores and the names of the participants is lost.
Another data structure is needed to avoid losing the correspondence.
6.3. We need to join the lists¶
6.4. Using and sorting a dictionary¶
Using a dictionary and seeing all its elements iteratively.
Activity: CodeLens 6.4.1 (cl_l37_6_en)
Using a dictionary for the championship.
You have attempted of activities on this page
