-2

I have string:

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

GO, DF, MS

I need:

GO,DF,MS
Simeon Visser
  • 118,920
  • 18
  • 185
  • 180

3 Answers3

2

Try the following:

''.join(line.split())
aga
  • 27,954
  • 13
  • 86
  • 121
  • 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,750
  • 2
  • 27
  • 36
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,132
  • 1
  • 14
  • 28
  • 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