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

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

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

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
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
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment