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