QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 30

For `items.pop()` with no argument, which statements are true? Select all that apply.

  1. It returns the element it removes.Ճիշտ պատասխան
  2. It removes the first element by default.
  3. It removes the final element by default.Ճիշտ պատասխան
  4. It raises `IndexError` when the list is empty.Ճիշտ պատասխան

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

With no index supplied, `pop` removes the final element and returns that removed value. An empty list has no valid final position, so the operation raises `IndexError`, not `ValueError` and not a `None` result.

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

Սկսել վարժանքը
Հարց 30: For `items.pop()` with no argument, which statements are… · Python Fundamentals · Questena