Re: Any algorithm to preserve whitespaces?

Discussion in 'Python' started by Peter Otten, Jan 23, 2013.

  1. Peter Otten

    Peter Otten Guest

    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(" ")
     
    Peter Otten, Jan 23, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Santosh Kumar

    Any algorithm to preserve whitespaces?

    Santosh Kumar, Jan 19, 2013, in forum: Python
    Replies:
    0
    Views:
    145
    Santosh Kumar
    Jan 19, 2013
  2. Lie Ryan
    Replies:
    0
    Views:
    147
    Lie Ryan
    Jan 19, 2013
  3. Mitya Sirenef

    Re: Any algorithm to preserve whitespaces?

    Mitya Sirenef, Jan 19, 2013, in forum: Python
    Replies:
    0
    Views:
    145
    Mitya Sirenef
    Jan 19, 2013
  4. Santosh Kumar

    Re: Any algorithm to preserve whitespaces?

    Santosh Kumar, Jan 23, 2013, in forum: Python
    Replies:
    0
    Views:
    107
    Santosh Kumar
    Jan 23, 2013
  5. Dave Angel
    Replies:
    0
    Views:
    107
    Dave Angel
    Jan 23, 2013
Loading...

Share This Page