Which fix removes the bug?
def top(words):
return sorted(words, key=len(words))
- Pass the function itself:
key=len - Pass the function itself:
key=len() - Change
sortedtowords.sort(len) - Add
reverse=Trueto the sorted call
key takes a function to call per item;
Play Problem Solving ▸
len(words) passes a number instead.