Any algorithm to preserve whitespaces?

Peter Otten __peter__ at
Wed Jan 23 10:46:50 CET 2013

Santosh Kumar wrote:

> I am in a problem.
>     words = line.split(' ')
> preserve whitespaces but the problem is it writes an additional line
> after every line.

Strip off the newline at the end of the line with:

line = line.rstrip("\n")
words = line.split(" ")

More information about the Python-list mailing list