QuestenaПрактика, после которой понятно, что повторить
Вопрос 102

Given text = "abc", what happens when Python evaluates text[::0]?

  1. It returns an empty string.
  2. It raises ValueError.Правильный ответ
  3. It repeats the first character forever.
  4. It returns the original string.

Объяснение

A slice step describes movement between selected positions, and zero cannot advance in either direction, so Python raises ValueError. It does not interpret zero as a request for an empty result or an endless repetition.

Продолжить работу с тестом

Начать тренировку
Вопрос 102: Given text = "abc", what happens when Python evaluates… · Python Fundamentals · Questena