Sorting
sorted() returns a new sorted list, and key chooses what to compare.
Example
words = ["pear", "fig"]
print(sorted(words, key=len))
Your task
Sort names by length, shortest first, and print the list.
DSA & Problem Solving
sorted() returns a new sorted list, and key chooses what to compare.
words = ["pear", "fig"]
print(sorted(words, key=len))
Sort names by length, shortest first, and print the list.
This lesson is checked against the lesson rules. Your code is never run on our servers.