Last active
April 30, 2023 09:38
-
-
Save TomoG29/1838dc8f8643ecf6db4df4df7fcce19a 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
str1 = "abcd abcd abcd" | |
str2 = str1.replace("ab","1") | |
print(str2) | |
#1cd 1cd 1cd | |
print(str1.replace("ab","x",2)) | |
#xcd xcd abcd | |
print(str1.replace("a","")) | |
#bcd bcd bcd | |
print(str1.replace("a","1").replace("b","2")) | |
#12cd 12cd 12cd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment