How can I replace something in a string in a list only if the string contains it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can I replace something in a string in a list only if the string contains it

https://code.sololearn.com/czE9FgOD7IZ5/#py I want to remove the commas and my txt file contains integers that some of them contain a comma

2nd Jul 2018, 3:01 PM
David Gedalia Ordman
David Gedalia Ordman - avatar
1 Answer
+ 3
This should remove commas for you: content = [element.replace(",", "") for element in content]
3rd Jul 2018, 3:00 AM
John Wells
John Wells - avatar