QuestenaPractice that shows what to review next
Question 31

After `items = [3, 1, 2]` and `result = items.sort()`, what are `items` and `result`?

  1. `items` stays `[3, 1, 2]`; `result` is `[1, 2, 3]`.
  2. `items` is `[1, 2, 3]`; `result` is `None`.Correct answer
  3. Both names refer to the same sorted list.
  4. `items` is `None`; `result` is `[1, 2, 3]`.

Explanation

The method rearranges the existing list into sorted order and follows the in-place-method convention of returning `None`. Expecting `result` to hold a sorted list confuses `list.sort` with the separate `sorted` function.

Continue with this test

Start practice
Question 31: After `items = [3, 1, 2]` and `result = items.sort()`, what… · Python Fundamentals · Questena