Jan-13-2024, 11:21 AM
The string method
replace
returns a copy of the string with all occurrences of substring old replaced by new.old_text = " A B C D " new_text = old_text.replace(" A ", " a ") print(old_text) print(new_text)
Output: A B C D
a B C D