SyntaxFix
Write A Post
Hire A Developer
Questions
strip only removes characters from the beginning and end of a string. You want to use replace:
strip
replace
str2 = str.replace("\n", "") re.sub('\s{2,}', ' ', str) # To remove more than one space