- 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.
- s="hello world"
- s=s.replace("hello world","my name is hello")
- print(s)
Output: my name is hello
No comments