Retour aux quiz
Débutant

Slicing sur une chaîne

Que va afficher ce code ?

quiz.py
1
Que va afficher le code suivant ? text = 'Comment Coder' result = text[1::2] print(result)

Réponses possibles

AComment Coder
BCmetCdr
Comn oe
DUne erreur

Explication

Avec [1::2] on commence à l'index 1 et on prend un caractère sur 2. En utilisant ce slicing (découpage) sur 'Comment Coder', on obtient 'omn oe'.