How to strip comma in Python string

msampaio picture msampaio · Apr 26, 2013 · Viewed 164.8k times · Source

How can I strip the comma from a Python string such as Foo, bar? I tried 'Foo, bar'.strip(','), but it didn't work.

Answer

eumiro picture eumiro · Apr 26, 2013

You want to replace it, not strip it:

s = s.replace(',', '')