[Python] Python Remove last char from string and return it

Discussão em 'Python' iniciado por Stack, Março 11, 2025.

  1. Stack

    Stack Membro Participativo

    While I know that there is the possibility:

    >>> a = "abc"
    >>> result = a[-1]
    >>> a = a[:-1]


    Now I also know that strings are immutable and therefore something like this:

    >>> a.pop()
    c


    is not possible.

    But is this really the preferred way?

    Continue reading...

Compartilhe esta Página