replace function:python having different types of in-built functions from them replace() is one of the function.
- The replace() function name itself saying that "one string is replaced with the other string".
- It consists of three parameters old value, new value, and count.
new value: The value we want to replace with is the new value.
count: The number of times of the value we want to replace old with the new value.
Syntax: str.replace(old value,new value,count)
#write a python code to demonstrate replace function.
- a="my name is java"
- b=" she is a very talented person"
- c="They have no knowledge in python"
- b=b.replace("talented person","brave girl")
- In the above program in line 5, we want to replace no with more and we gave the count as 3 so in the string where we have no that will be replaced with more up to 3 times only.
- so the output will be as shown in below.