[Python] Why doesn't calling a string method (such as .replace or .strip) modify (mutate) the...

Discussão em 'Python' iniciado por Stack, Outubro 7, 2024.

  1. Stack

    Stack Membro Participativo

    I wrote this Python program to do a simple string replacement:

    X = "hello world"
    X.replace("hello", "goodbye")


    After this, the value of X was "hello world". Why didn't it changed to "goodbye world" instead?

    Continue reading...

Compartilhe esta Página