-2

I have string:

lote1 = 'GO, DF, MS'
lote1.strip()
print(lote1)

GO, DF, MS

I need:

GO,DF,MS
Simeon Visser
  • 113,587
  • 18
  • 171
  • 175

3 Answers3

2

Try the following:

''.join(line.split())
aga
  • 27,056
  • 10
  • 81
  • 117
  • 1
    @CristianoPires you're welcome. :) please, accept my answer (or whichever helped you the most) by clicking on the tick button in front of the answer. – aga Nov 05 '13 at 18:27
2

Use this: lote1.replace(' ', '')

Jack
  • 2,640
  • 2
  • 25
  • 35
2

The question is too vague.

Just in case you need just to strip space both at the beginning and the end of comma-delimited strings:

> s = "   foo bar bar  baar  ,   foo bar , foo bar bar bar "
> ",".join(x.strip() for x in s.split(","))
'foo bar bar  baar,foo bar,foo bar bar bar'
Alicia
  • 1,112
  • 1
  • 14
  • 27
  • Funny story, I am the case that just needed to strip whitespace. Thanks for being thorough for the hell of it. – Inversus May 27 '14 at 13:43