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

For items = ["a", "b", "c"], which statement describes items[-1]?

  1. It selects the first item, 'a'.
  2. It raises IndexError because negative indexes are invalid.
  3. It selects the final item, 'c'.Ճիշտ պատասխան
  4. It returns None.

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

A negative index counts backward from the end, and -1 designates the final list item, c. It is valid for a nonempty sequence and does not wrap around to the first item.

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

Սկսել վարժանքը
Հարց 98: For items = ["a", "b", "c"], which statement describes… · Python Fundamentals · Questena