| Name | .replace() |
||||
|---|---|---|---|---|---|
| Examples |
word = "cake"
print(word) # Prints cake
word = word.replace('c', 'm')
print(word) # Prints make
| ||||
| Description | Returns a copy of the string with all occurrences of an old substring replaced by a new substring. | ||||
| Syntax | s.replace(old, new) | ||||
| Parameters |
| ||||
| Related |
.split() .join() .strip() .find() String Formatting |
Updated on Thu Oct 22 12:07:48 2026.
If you see any errors or have comments, please let us know.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License