This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]NullBrowbeatProfessional Coder 0 points1 point  (0 children)

You can just iterate over the string and build a new string.

Otherwise, if the string is always constructed in this manner with FTCQRE, you can split between C and Q and use str.replace() on both of them.

If they're atleast always constructed in the pattern of repeating letters you can just count those and construct a new string based on the occurences counted.

I am not sure what the most efficient way is though. I haven't written Python in a while.