Search and Replace in Strings : Replace « String « Python Tutorial






question = "What is the air speed velocity of an unlaiden swallow?"
print question
question2 = question.replace("swallow", "European swallow")
print question2
question3 = question.replace("swallow", "African swallow")
print question3








5.23.Replace
5.23.1.The replace method returns a string where all the occurrences of one string have been replaced by another:
5.23.2.Search and Replace in Strings
5.23.3.replacing a substring