QuestenaPractice that shows what to review next
Question 27

A list starts as `items = [1]`. What is its value after `items.extend([2, 3])`?

  1. `[1, [2, 3]]`
  2. `[2, 3]` while `items` stays `[1]`
  3. `[1]` because extend returns an iterator
  4. `[1, 2, 3]`Correct answer

Explanation

The iterable supplies two successive elements, and `extend` appends each of them to the existing list. Treating the argument as one nested element confuses this method with `append`.

Continue with this test

Start practice
Question 27: A list starts as `items = [1]`. What is its value after… · Python Fundamentals · Questena