join()
is an operator on a string, and it doesn't modify anything. It returns a new string.Since you're not assigning the result of the join, the result is thrown away and y remains the same.
y = "Hello, world!" l = ["one", "two", "three"] y.join(l) print(y) # no change y = y.join(l) # assigns the change back to y print(y) # now the change is seen
Output:Hello, world!
oneHello, world!twoHello, world!three
That said, I'm not sure you want to join()
at all. It sounds like you just want to concatenate two strings. You can do that with a plus symbol if you have two strings.