I've always thought that strings and tuples are immutable in Python. But now I've been confused with this function that I wrote (down below). When it's executed, I get a mutable string indeed. Am I missing something here?
def example():
string = "/*Jon is @developer & musician"
for char in string:
if not char.isalpha():
string = string.replace(char, '#')
return(string)
Output:
>>> example()
'##Jon#is##developer###musician'
>>>
Thanks in advance for your explanation!