I am attempting to replace multiple letters within a string, I want the vowels to be replaced by the users input, and my current code replaces all the vowels with the same letters, however I want to replace the vowels with different user inputs. Below is an example of what I would like, and the code below that.
What I want
input1 = zz
input2 = xx
input3 = yolo
output = yzzlxx
What I have
input1 = zz
input2 = xx
input3 = yolo
output = yzzlzz
Here is my code.
def vwl():
syl1 = input("Enter your first syllable: ")
syl2 = input("Enter the second syllable: ")
translate = input("Enter word to replace vowels in: ")
for ch in ['a','e','i','o','u']:
if ch in translate:
translate=translate.replace(ch,syl1,)
for ch in ['a','e','i','o','u']:
if syl1 in translate:
translate=translate.replace(ch,syl2,)
print (translate)
homework
tag has recently been deprecated. See here. – DSM Sep 24 '12 at 15:31