Reading about Python? Actually practice it. Try PyChallenge free

Python Tutorial

String replace

The method replace returns a new string with old replaced by new.

Syntax

The format is:
str.replace(old, new, max)

Parameters

Example

s = "All work and no play makes Jack a dull boy. Jack?"
s = s.replace("Jack","Joe")
print(s)

Result:

All work and no play makes Joe a dull boy. Joe?

Practice
Stop reading. Start writing Python.
PyChallenge gives you interactive exercises in your browser — no install needed.
Practice Python with interactive exercises
Parameter
old The string to be replaced
new The string to be used
max Maximum amount of replacements.Leave blank for infinite.