Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

python replaceall

  • In python, replace all is similar to replace() function. 
  • Here we are going to replace all the characters with new characters.
  • It also consists of 3 parameters like new value, old value, count.
  • The old value is the string that we have already given in string.
  • The new value is the that is to be replaced with.
  • The count is the number of times that string to be replaced in the string.
Syntax:  str.replace(old value,new value,count)

#write a python code to demonstrate the replace function.

  1. s="hello world"
  2. s=s.replace("hello world","my name is hello")
  3. print(s)
Output:    my name is hello




This post first appeared on Java Tutorial - InstanceOfJava, please read the originial post: here

Share the post

python replaceall

×

Subscribe to Java Tutorial - Instanceofjava

Get updates delivered right to your inbox!

Thank you for your subscription

×