• 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


Instance Of Java

We are here to help you learn! Feel free to leave your comments and suggestions in the comment section. If you have any doubts, use the search box on the right to find answers. Thank you! 😊
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu