I have a string in my code (which consists entirely of lower-case alphabets). I need to replace a character conditional on the appearance of another character after the character I intend to replace in the same string. For example if the character to be replaced is “e” and the conditional character is “t”, then we will replace “e” in “forest” but not in “jungle”
Is there is way to do this in a simple manner in Python? Thanks for taking out time for this problem.
P.S Please note that there is no repetition of alphabets in the characters I am working with.
What’s wrong with?
and its readable
If the occurrence is not unique you can also do