6. What are the names of the winners?

6.1. Using another list

  • We can use two lists to find out.

  • The names and scores lists to save the names and scores obtained by the participants respectively.

Data file: surf4_en.txt
Johny 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 names list 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.

    On a scale from 1 (needs improvement) to 3 (excellent), how would you rate this chapter?
  • 1
  • 2
  • 3
You have attempted of activities on this page