Python 3 Script to Remove Commas From String Using replace() Method and regex Package Full Project For Beginners

 

Welcome folks today in this blog post we will be removing commas from string using replace() method and regex package in python All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make a app.py file and copy paste the following code

 

 

app.py

 

 

using replace() method

 

 

string="c,ode,spe,edy.com" #string
string_dup=string.replace(',',"") #copying the output from replace to another varialbe
print(string_dup) #printing the string without commas

 

 

using regex package

 

See also  Python 3 Cricbuzz API Example to Scrape IPL League Players Statistics and Download it as CSV File Using BeautifulSoup4 Library Full Project For Beginners

 

 

import re #import the package
string="c,ode,spe,edy.com" #input string
print(re.sub(",","",string)) #replace the commas with null and print the string

 

 

Leave a Reply