mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-17 11:17:36 +00:00
Update replace.py
This commit is contained in:
parent
19db3e369f
commit
ce03ae6822
@ -1,9 +1,8 @@
|
|||||||
def string_replace(
|
def string_replace(text: str, input_string: str, replace_with_string: str, occurrence: int) -> str:
|
||||||
text: str, input_string: str, replace_with_string: str, occurrence: int
|
|
||||||
) -> str:
|
|
||||||
"""
|
"""
|
||||||
|
https://docs.python.org/3/library/stdtypes.html#str.replace
|
||||||
The replace() method replaces a specified string with another specified string.
|
The replace() method replaces a specified string with another specified string.
|
||||||
The occurence parameter can be skipped in order to consider all text.
|
The occurrence parameter can be skipped in order to consider all text.
|
||||||
Note: input and replace_with strings are case-sensitive.
|
Note: input and replace_with strings are case-sensitive.
|
||||||
>>> text = "One Two Two Three Four Five"
|
>>> text = "One Two Two Three Four Five"
|
||||||
>>> string_val = string_replace(text, "Two", "Seven", 1)
|
>>> string_val = string_replace(text, "Two", "Seven", 1)
|
||||||
@ -20,5 +19,4 @@ def string_replace(
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from doctest import testmod
|
from doctest import testmod
|
||||||
|
|
||||||
testmod()
|
testmod()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user