Feb-07-2018, 10:33 PM
Is this the best practice for assigning to a string slice? I realized in that case I could have used replace(), but I was thinking of the general case, e.g. I have located a pattern in the string.
>>> sf='23'
>>> s='1234'
>>> i=s.find( sf)
>>> s[:i] + s[i+len(sf)]
'14'
>>> sf='23'
>>> s='1234'
>>> i=s.find( sf)
>>> s[:i] + s[i+len(sf)]
'14'