strip() returns the string with leading and trailing whitespaces(by default) removed.
So it would turn " Hello World "
to "Hello World"
, but it won't remove the \n character as it is present in between the string.
Try replace().
str = "Hello \n World"
str2 = str.replace('\n', '')
print str2