QuestenaUn entraînement qui indique quoi revoir ensuite
Question 102

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

  1. It returns an empty string.
  2. It raises ValueError.Bonne réponse
  3. It repeats the first character forever.
  4. It returns the original string.

Explication

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.

Continuer avec ce test

Commencer l’entraînement
Question 102: Given text = "abc", what happens when Python evaluates… · Python Fundamentals · Questena