So I have a long list of strings in the same format, and I want to find the last \".\" character in each one, and replace it with \". - \". I\'ve tried using rfind, but I can\'t
To replace from the right:
def replace_right(source, target, replacement, replacements=None): return replacement.join(source.rsplit(target, replacements))
In use:
>>> replace_right("asd.asd.asd.", ".", ". -", 1) 'asd.asd.asd. -'