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

What is the correct fix?

items = ['b', 'a']
sorted(items)
print(items[0])
  1. Assign it: items = sorted(items) instead
  2. Assign it: items = items.sorted() instead
  3. Change sorted(items) to items.sort only
  4. Print items[-1] to read the first value
sorted() returns a new list and leaves the original untouched; the result was discarded.
Play Problem Solving ▸