Because strings in python are immutable: once created, it can't be changed - all you can do is create a new string from the original with your changes applied.
So because
replace
can't alter the original string, it returns a new, modified one instead. You need to save the new one in a string variable, or it will be discarded.
In addition
'one'
is a literal string, it has nothing to do with the variable called
one
.
So your code will try to replace the letters
one
with the letters
two
in the string
x
, not find any, so it returns a new string that is identical to the first, and you then throw that away anyway!
Try this:
x='07:05:45'
one=x[:-6]
two=int(one)+int(12)
x = x.replace(str(one),str(two))
print(str(x))
But ... be aware that if the minutes or seconds are "07" then they will be replaced with "19" as well ...