[Python] Using strip() to remove only one element

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

  1. Stack

    Stack Membro Participativo

    I have a word within two opening and closing parenthesis, like this ((word)). I want to remove the first and the last parenthesis, so they are not duplicate, in order to obtain something like this: (word).

    I have tried using strip('()') on the variable that contains ((word)). However, it removes ALL parentheses at the beginning and at the end. Result: word.

    Is there a way to specify that I only want the first and last one removed?

    Continue reading...

Compartilhe esta Página