Answers for "how to replace 2 letters in a string python"

4

python substitute multiple letters

message = "h@ll$ w$rld"
# make the replacement ('!'->'a', '@'->'e', etc.)
message.translate(str.maketrans("!@#$%", "aeiou"))
# outputs hello world
Posted by: Guest on May-26-2021
0

how to replace a single letter in a string python

text = "abcdefg";
text[1] = "Z";
Posted by: Guest on August-13-2021

Code answers related to "how to replace 2 letters in a string python"

Python Answers by Framework

Browse Popular Code Answers by Language