You want to replace it, not strip it:

s = s.replace(',', '')
Answer from eumiro on Stack Overflow
🌐
Jeremy Morgan
jeremymorgan.com › python › how-to-remove-comma-from-string-in-python
How to Remove Comma from String in Python
December 14, 2023 - This will remove all commas from the string and print the result. Regular expressions are a powerful tool for working with text data in Python. You can use them to search for specific patterns, such as commas, and replace them with another value.
Discussions

csv - Remove comma from middle of string in python - Stack Overflow
My problem is stripping a comma out from a string. This string contains two commas and when this second comma is included in my list of strings, it interferes when writing to a CSV in the proper ma... More on stackoverflow.com
🌐 stackoverflow.com
Python: Remove everything after first comma in string
Try .split(",")[0]. More on reddit.com
🌐 r/learnpython
4
1
May 28, 2022
Efficient Way To Remove Repeating Commas From String
', '.join([x.strip() for x in my_string.split(',') if not x.isspace() and x != '']) More on reddit.com
🌐 r/learnpython
9
2
December 1, 2022
I must be an idiot or something. Why can't I strip the comma's out of a string?
Maybe you're thinking of split()? test = '12,123,123,123' test2 = test.split(',') test2 ['12','123','123','123'] Concat the elements and the commas are gone :) More on reddit.com
🌐 r/learnpython
21
6
February 13, 2012
🌐
Reddit
reddit.com › r/learnpython › efficient way to remove repeating commas from string
r/learnpython on Reddit: Efficient Way To Remove Repeating Commas From String
December 1, 2022 -

I have a string that consists of something like:

my_string = 'Now is the time, , for all good men,   , ,to come to the aid,, of their party'

...and I want to keep only a single comma for each repeating set of commas:

result = 'Now is the time, for all good men, to come to the aid, of their party'

I've looked a numerous methods to remove sequential characters, but 1) these are not sequential (may have one or more blanks between them); and 2) I only want to remove the extra commas and not other repeating characters that might appear in the string.

Any help would be greatly appreciated.

🌐
Stack Abuse
stackabuse.com › how-to-remove-commas-from-a-string-in-python
How to Remove Commas from a String in Python
June 12, 2023 - Python's built-in string method replace() is an easy-to-use function for removing characters from a string. The replace() method replaces a specified phrase with another specified phrase, and it's a perfect fit for our problem: # Given string s = "H,e,l,l,o, W,o,r,l,d" # Removing commas from the string s = s.replace(",", "") print(s)
🌐
HackerNoon
hackernoon.com › how-to-remove-commas-from-string-python
How to Remove Commas From String Python | HackerNoon
July 18, 2022 - We will use replace the () function to remove all commas from the string. replace() is an in-built function in Python, where replace() function is used to replace any characters from the given strings or is used to replace all occurrences of ...
🌐
PythonForBeginners
pythonforbeginners.com › home › remove commas from string in python
Remove Commas From String in Python - PythonForBeginners.com
February 9, 2022 - Regular expressions are a great tool to manipulate strings. We can also use them to remove commas from a string in python.
🌐
AskPython
askpython.com › python › string › strip-last-comma-from-strings
4 Ways to Strip the Last Comma from Strings in Python - AskPython
April 29, 2023 - The original string is= Our text will be here, The final string after removing the last comma is= Our text will be here · Using Replace() Function. This method is another very common method used for stripping strings only up to the required ...
Find elsewhere
🌐
Delft Stack
delftstack.com › home › howto › python › remove commas from string in python
How to Remove Commas From String in Python | Delft Stack
February 2, 2024 - To remove comma from a string in Python, we can use the str.replace() method and the re package.
🌐
CodeSpeedy
codespeedy.com › home › how to remove comma from a string in python
How to remove comma from a string in Python - CodeSpeedy
April 3, 2021 - Python consists of a built-in package called re which can be used to work with regular expressions. This package can be used to work with regular expressions. We can use the function re.sub() of this package to remove commas from the string.
🌐
Python Guides
pythonguides.com › remove-commas-from-a-string-in-python
How To Remove Commas From A String In Python?
March 19, 2025 - Read How to Insert a Python Variable into a String? The simplest way to remove commas from a string is by using the built-in replace() method. It allows you to replace a specific substring with another substring or an empty string.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › how to remove commas from a string python
How to Remove Commas from a String Python - Spark By {Examples}
November 7, 2024 - How to remove commas from a string in Python? To remove commas from a string you can use multiple approaches of Python. You can use some of the approaches
🌐
Finxter
blog.finxter.com › home › learn python blog › how to remove a comma from a string? 5 best ways
How to Remove a Comma from a String? 5 Best Ways - Be on the Right Side of Change
May 23, 2022 - This method uses replace() from Python’s built-in string library to remove the comma/commas and return a new string with the modifications made.
🌐
Stack Overflow
stackoverflow.com › questions › 59583432 › remove-comma-from-middle-of-string-in-python
csv - Remove comma from middle of string in python - Stack Overflow
The csv module will normally quote strings containing a comma, so you should provide your code to see what is going wrong. replacing the comma isn't the answer. ... You can remove the comma as follows.
🌐
Linux Hint
linuxhint.com › remove-string-commas-python
Linux Hint – Linux Hint
November 10, 2021 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
sebhastian
sebhastian.com › remove-commas-from-string-python
How to remove commas from a string in Python | sebhastian
April 11, 2023 - To remove commas, you can specify an empty string as the new substring as follows: origin_str = "It, is, a, lovely, day," new_str = origin_str.replace(',', '') print(origin_str) # It, is, a, lovely, day, print(new_str) # It is a lovely day · ...
🌐
Tutorial Reference
tutorialreference.com › python › examples › faq › python-how-to-remove-commas-from-string
How to Remove Commas from a String in Python | Tutorial Reference
The str.replace() method is the standard, most readable, and efficient way to remove commas or any other substring from a string in Python.
🌐
Quora
quora.com › How-do-you-remove-the-comma-completely-in-Python
How to remove the comma completely in Python - Quora
Answer (1 of 5): Don’t put any of those variables inside repr(). You must understand what you are doing here. repr is a function that returns a representation of its input, one which hopefully can be read back as valid python code. Since string literals in python have quotes, those quotes ...