Python Kwararrun replace() Method
Daffin
Wuce kuma daffi "bananas":
txt = "I like bananas" x = txt.replace("bananas", "apples") print(x)
Definition and Usage
The replace() method replaces a specified phrase with another specified phrase.
Comment:If no other content is specified, it will replace all occurrences of the specified phrase.
Syntax
string.replace(oldvalue, newvalue, count)
Parameters Value
Parameters | Ba'amfani |
---|---|
oldvalue | Wajib. Kwallon daffi wanda ake nemi. |
newvalue | Wajib. Kwallon daffi wanda ake tura sake sai. |
count | Optional. Dababa, ta tuntabe kwallon daffi wanda ake tura sake sai. Tsarin da ake tura shine duk daffin. |
Daffin Kudu
Daffin
Wuce daffi duka daga "one":
txt = "one one was a race horse, two two was one too." x = txt.replace("one", "three") print(x)
Daffin
Wuce kuma daffi farko daga "one":
txt = "one one was a race horse, two two was one too." x = txt.replace("one", "three", 2) print(x)