Python ProgrammingPython Programming

How to use string.replace() in Python?

a = "This is the island of istanbul"
print (a.replace("is" , "was", 1))
print (a.replace("is" , "was", 2))
print (a.replace("is" , "was"))
Output
Thwas is the island of istanbul
Thwas was the island of istanbul
Thwas was the wasland of wastanbul