QuestenaPractice that shows what to review next
Question 29

A list is `[4, 2, 4]`. Which description of `items.remove(4)` is correct if `items` refers to that list?

  1. It deletes both occurrences and leaves `[2]`.
  2. It deletes the first matching value and leaves `[2, 4]`.Correct answer
  3. It deletes the element at index 4.
  4. It ignores a missing value without an exception.

Explanation

The method searches by equality and deletes only the earliest matching element, leaving `[2, 4]`. It does not interpret 4 as an index or remove every duplicate, and absence would produce `ValueError` rather than a silent no-op.

Continue with this test

Start practice
Question 29: A list is `[4, 2, 4]`. Which description of… · Python Fundamentals · Questena