Notice that the string type is immutable. So the str.replace method does not replace the characters in place. You have to assign the returned value to a variable:
s = s.replace("g","#")There is no reason for an error.