Skip to navigation
Replace Last Occurrence of a String with python
18.03.22
def replace_last(string, find, replace): reversed = string[::-1] replaced = reversed.replace(find[::-1], replace[::-1], 1) return replaced[::-1] result = replace_last("Hello World, Hello World.", "Hello", "Hi") print(result)
https://bytenota.com/python-replace-last-occurrence-of-a-string/
Reply
Anonymous
Information Epoch 1760638409
Worse is better.
Home
Notebook
Contact us