I want to do a string replace in Python, but only do the first instance going from right to left. In an ideal world I\'d have:
myStr = \"mississippi\" print
You could also use str.rpartition() which splits the string by the specified separator from right and returns a tuple:
myStr = "mississippi" first, sep, last = myStr.rpartition('iss') print(first + 'XXX' + last) # missXXXippi