$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #207

Which fix removes the bug?

scores = ['9', '10', '100']
print(max(scores))  # expected 100
  1. Compare with key=int
  2. Use sorted(scores)[-1]
  3. Call max(*scores) here
  4. Use scores.max() instead
Strings compare character by character, so '9' beats '100'; key=int compares them as numbers.
Play Problem Solving ▸