# you probably want to use a space ' ' to replace `\n` mystring = mystring.replace('\n', ' ').replace('\r', '')