Python Replace Char In String Using Context