Use correctly replace function in python