I have a string representing a date like: yymmdd
(for example, 170901
for the 1st of September of 2017), obtained from a datetime
object.
I want to replace the leading zeros of each field by a blank space. str.replace()
won't do it it because it replaces the trailing zeros as well.
What would be the Pythonic way of substituting a character for another in a string but only in certain positions (in this case in the even indexes of the string)?