-
-
Save IndhumathyChelliah/2f37ad9cd54e576a0d106ff340d5a97f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if count not specified, it replaces all occurences of substring | |
s1="red blue green red orange green" | |
print (s1.replace("red","aaaaa"))#Output:aaaaa blue green aaaaa orange green | |
#count is mentioned as 1. So only first occurence is replaced. | |
print (s1.replace("red","***",1))#Output:*** blue green red orange green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment