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

Which fix removes the bug?

def top(words):
    return sorted(words, key=len(words))
  1. Pass the function itself: key=len
  2. Pass the function itself: key=len()
  3. Change sorted to words.sort(len)
  4. Add reverse=True to the sorted call
key takes a function to call per item; len(words) passes a number instead.
Play Problem Solving ▸