QuestenaПрактика, после которой понятно, что повторить
Вопрос 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]`Правильный ответ

Объяснение

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`.

Продолжить работу с тестом

Начать тренировку
Вопрос 27: A list starts as `items = [1]`. What is its value after… · Python Fundamentals · Questena