0

How can I convert the string (s) into required string (ans)? This is simple string manipulation in python.

s = '(107, 163, 138, 255)'


ans = '(107,163,138,255)'
tripleee
  • 175,061
  • 34
  • 275
  • 318
puti
  • 537
  • 1
  • 5
  • 9
  • use `ans = s.replace(" ","")` – Tanmaya Meher Aug 22 '14 at 06:51
  • [possible duplicate](http://stackoverflow.com/questions/8270092/python-remove-all-whitespace-in-a-string). Here you can find different methods to remove spaces in different places / complete removal of spaces of a string – Tanmaya Meher Aug 22 '14 at 07:03

1 Answers1

5

Use the replace method to replace the whitespace with nothing:

>>> s = '(107, 163, 138, 255)'
>>> s.replace(" ", "")
'(107,163,138,255)'
Jose Magana
  • 931
  • 3
  • 10
  • 24