I mean, i want to replace str[9:11] for another string. If I do str.replace(str[9:11], \"###\") It doesn\'t work, because the sequence [9:11] can b
str[9:11]
str.replace(str[9:11], \"###\")
you can do
s="cdabcjkewabcef" snew="".join((s[:9],"###",s[12:]))
which should be faster than joining like snew=s[:9]+"###"+s[12:] on large strings
snew=s[:9]+"###"+s[12:]