str.replace

Copy of source with one occurrence of target replaced: occurrence 0 is the first, 1 the second (default 0). Unchanged when there is no such occurrence.

str.replace(source: string, target: string, replacement: string, occurrence: int = 0) -> string

Parameters

Example

s = str.replace("1-2-3", "-", "/", 1)