practicepython.in
python exercises
171 exercises

Daily #17 · 15 October 2026

Alphabetical, sort of Medium

What does this print?

print(sorted(["banana", "Apple", "cherry", "Date"]))
  1. A['banana', 'cherry', 'Apple', 'Date']
  2. B['Apple', 'Date', 'banana', 'cherry']
  3. C['Date', 'Apple', 'cherry', 'banana']
  4. D['Apple', 'banana', 'cherry', 'Date']
Show the answer

B: ['Apple', 'Date', 'banana', 'cherry']

Why: Strings sort by character code, and every capital letter comes before every lower-case one. sorted(words, key=str.lower) sorts the way a person would.

Play today’s puzzle →