replace first python code example
Example 1: python replace first
'TESTstringTEST'.replace('TEST', 'replaced', 1)
# output 'replacedstringTEST'
Example 2: python replace only first instance
text.replace("text", "new", count)
# count is the number of instances you want to replace