I have the following string, where the substring 2.5 was incorrectly formed: 'It costs 2. 5. That is a lot.'
How do I remove the space between the 2. and the 5?
I tried:
s = 'It costs 2. 5. That is a lot.'
s = s.replace('. ', '.')
print(s) # It costs 2.5.That is a lot.
However, that also remove the correctly-placed space between the 5. and T. I think I'm looking for a sed-style regex substitution variable, like s/\. \([0-9]\)/.\1/g. How do I do that in Python?