I have a str
ing which is a combination of "S"s and "C"s. There is at least one occurrence of each.
I want to find the last occurrence of "CS" and change it to "SC".
I have two methods (so far):
P = P[::-1].replace("SC", "CS", 1)[::-1]
and
P = P[:P.rfind("CS")] + "SC" + P[P.rfind("CS") + 2:]
Which line is likely to be faster? Also, is there a quicker way to achieve what I'm doing?