[Python] Why is -1 returned if the character is not found in a string?

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

  1. Stack

    Stack Membro Participativo

    This returns -1 Why is that?

    a = "apples"

    print(a.find("g"))


    This can be generated if you try to find a character that is nonexistent to the string.

    Continue reading...

Compartilhe esta Página