I have a string and I want to remove duplicate spaces from that. But my string has a new line character \n and after doing this, this character also is deleted.
Output of this:
s = 'A B     C  D \n EF   G'
print(s)
s = " ".join(s.split())
print(s)
is as follows:
A B     C  D 
 EF   G
------------
A B C D EF G
But I do not want to remove this character. The desired output:
A B C D
 EF G
 
     
     
     
    