3

ok I know that this should be simple... anyways say:

line = "$W5M5A,100527,142500,730301c44892fd1c,2,686.5  4,333.96,0,0,28.6,123,75,-0.4,1.4*49"

I want to strip out the spaces. I thought you would just do this

line = line.strip()

but now line is still '$W5M5A,100527,142500,730301c44892fd1c,2,686.5 4,333.96,0,0,28.6,123,75,-0.4,1.4*49' instead of '$W5M5A,100527,142500,730301c44892fd1c,2,686.54,333.96,0,0,28.6,123,75,-0.4,1.4*49'

any thoughts?

2
  • 5
    strip only removes spaces from the beginning or the end of the string. Also, how about going back to your old questions and marking good answers as accepted answers? Commented Jun 1, 2010 at 14:13
  • I just did, I am new to stackoverflow, thx for reminding me of my duties. Commented Jun 1, 2010 at 16:56

2 Answers 2

11
line = line.replace(' ', '')
Sign up to request clarification or add additional context in comments.

Comments

0

another way of doing it

line = ''.join(line.split())

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.