Change the 9 to a 10:
if temp2[4] == '-' and temp2[10] != '-':
temp3 = temp2[:10] + '-' + temp2[10:]
When you call a string its str[from:to]
, so temp2[:9]
is equivalent to temp2[0:9]
and it would only return the characters from 0-9 instead of the required 0-10
0
solved Python String unwanted overwrite