I need to replace the string in last occurrence after splitting the string
I have tried the below way but it is giving incorrect output like 1.120
below is the code which I have tried.
y = "1.19-test"
if '-' in y:
splt = (int(y.split('-')[0][-1]) + 1)
str = y[::-1].replace(y.split('-')[0][-1], str(splt)[::-1], 1)[::-1]
print str
else:
splt = (int(y.split('.')[-1]) + 1)
str = y[::-1].replace(y.split('-')[0][-1], str(splt)[::-1], 1)[::-1]
print str
The output I'm getting like 1.120-test
. But here I need the output as 1.20-test