You want to replace it, not strip it:

s = s.replace(',', '')
Answer from eumiro on Stack Overflow
🌐
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 ...
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
how to remove the commas from a strings that contains commas in a list (Python) - Stack Overflow
This is just one line of a file that reads a list of numbers. I need to remove the commas in the numbers. These numbers are already strings. I am having trouble figuring out how to write this. ['0'... 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
🌐
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.

🌐
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.
🌐
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)
🌐
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 ...
🌐
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.
Find elsewhere
🌐
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
🌐
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.
🌐
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.
🌐
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.
🌐
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.
🌐
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.
🌐
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 · ...
🌐
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 ...
🌐
CSDN
devpress.csdn.net › python › 62f4e2bbc6770329307fa7a8.html
How to Remove Commas From String Python_python_Mangs-Python
August 11, 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 a substring from another substring.
🌐
Stack Overflow
stackoverflow.com › questions › 72496206
how to remove the commas from a strings that contains commas in a list (Python) - Stack Overflow
If the string doesn't contain ,, replace() will just return it unchanged. ... To modify the array value in place, you have to re-assign it. The below function illustrates how to do so. def remove_commas(array): for i in range(len(array)): if ',' in array[i]: array[i] = array[i].replace(',', '') return array
🌐
YouTube
youtube.com › techniquecoding
Remove Commas From String Python - YouTube
Python has a number of built-in functions that assist the users in executing different string manipulations. The replace() function is among the built-in fun...
Published   October 20, 2022
Views   1K