QuestenaPractice that shows what to review next
Question 102

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

  1. It returns an empty string.
  2. It raises ValueError.Correct answer
  3. It repeats the first character forever.
  4. It returns the original string.

Explanation

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.

Continue with this test

Start practice
Question 102: Given text = "abc", what happens when Python evaluates… · Python Fundamentals · Questena