QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 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]`.Ճիշտ պատասխան
  3. It deletes the element at index 4.
  4. It ignores a missing value without an exception.

Բացատրություն

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.

Շարունակեք այս թեստով

Սկսել վարժանքը