[Python] Given "myString[2:5]", is 2 the second index or the third?

Discussão em 'Python' iniciado por Stack, Fevereiro 20, 2025.

  1. Stack

    Stack Membro Participativo

    I'm very new to coding and this question keeps bothering me. I thought 2 would be the third index because the first index is 0, but my friend tells me 2 is "the second index but the third character", and now I'm really confused. Could someone help me with this? Thank you.

    I just tried with ChatGPT and it told me that 2 is the third index, but the slice begins with the second index, and now I'm more confused.

    Continue reading...

Compartilhe esta Página