QuestenaPractice that shows what to review next
Question 32

After `items = [3, 1, 2]` and `result = sorted(items)`, which state is correct?

  1. Both `items` and `result` are `[1, 2, 3]`.
  2. `items` is `[1, 2, 3]`; `result` is `None`.
  3. `items` stays `[3, 1, 2]`; `result` is `[1, 2, 3]`.Correct answer
  4. `result` is an iterator over the unchanged list.

Explanation

The built-in function constructs a new sorted list for `result` and leaves its input list in the original order. Saying the input is rearranged applies the behavior of `items.sort()` to the different `sorted` operation.

Continue with this test

Start practice
Question 32: After `items = [3, 1, 2]` and `result = sorted(items)`,… · Python Fundamentals · Questena