Skip to content

Instantly share code, notes, and snippets.

@TomoG29
Last active April 30, 2023 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TomoG29/1838dc8f8643ecf6db4df4df7fcce19a to your computer and use it in GitHub Desktop.
Save TomoG29/1838dc8f8643ecf6db4df4df7fcce19a to your computer and use it in GitHub Desktop.
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