I have a string '1472_1 2014-6-19'
and I want to replace whatever number is after the underscore(in this case number one) with the word 'Normal', what I did was to find the index of the element that I want replaced:
print line.replace(line[line.find('_') + 1:line.find(' ')],'Normal', 1)
But instead of getting '1472_Normal 2014-6-19'
, I got 'Normal472_1 2014-6-19'
It seems like my code replace the first 1 instead of the one after the underscore.
I have read this post: Replacing specific words in a string (Python) but still wondering is there a way to specify which element to be replaced instead of using regex?
And to be clear the number after underscore could be any number from 0 to 237