Retour aux quiz
Débutant

Extraction de suffixe avec indice négatif

Que retourne cette fonction ?

quiz.py
1
Que va afficher ce code Python ? s = "CommentCoder" print(s[-5:])

Réponses possibles

ACommentCoder
BUne erreur (IndexError: string index out of range)
CCoder
DComme

Explication

L'indice -5 commence 5 caractères avant la fin, donc ici "Coder".