The .replace() function replaces a specified phrase with another specified phrase.
All occurrences of the specified phrase will be replaced, if nothing else is specified.
the actual syntax for .replace function is as follows-
string.replace(oldvalue, newvalue, count)
oldvalue - The string to search for
newvalue - The string to replace the old value with
count(Optional)- A number specifying how many occurrences of the old value you want to replace. By Default is all occurrences
It happens similarly to Java as well, its not about python only, JAVA Syntex is-
public String replace(char oldChar, char newChar)
and
public String replace(CharSequence target, CharSequence replacement)
check out this example-
public class ReplaceExample1{
public static void main(String args[]){
String s1="javatpoint is a very good language";
String replaceString=s1.replace('a','e');//replaces all occurrences of 'a' to 'e'
System.out.println(replaceString);
}}
this will give result as follows in java
jevetpoint is e very good lenguege
if you want to replace "is" for your case you should use " is " it means you are using spacebar as an element for your string thus the required result will come-
print("This is it!".replace(" is ", " are "))
output- This are it!