I want to be able to replace each 'hello' in a string to 'newword' one time.
In the first output:
' Hello word word new word word word word hello'
the first hello only will be replaced.
In the second output:
'Hello word word hello word word word new word'
the second hello only will be replaced.
for example :
l = ' Hello word word hello word word word hello'
w = 'hello'
l=l.replace(w,'newword',1)
The code above just replace the first hello.
How can I be able to replace the second hello with keeping the first hello. is there any way to do that by (index)?
Thanks for help and hints.