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

What happens when Python evaluates "abc"[4]?

  1. It returns None.
  2. It returns 'c'.
  3. It raises KeyError.
  4. It raises IndexError.Ճիշտ պատասխան

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

The string has valid nonnegative positions 0 through 2, so direct access at 4 raises IndexError. Direct indexing does not clip an excessive position or return None as a sentinel.

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

Սկսել վարժանքը
Հարց 99: What happens when Python evaluates "abc"[4]? · Python Fundamentals · Questena