Sep-26-2017, 12:46 PM
Puny mortals, and iterating over characters in a word... (ie, if we're solving homework, at least give an answer that looks like they didn't do it themselves ;)
>>> def replace_vowel(words): ... replacements = str.maketrans({ch:"-" for ch in "aeiouAEIOU"}) ... for word in words: ... yield word.translate(replacements) ... >>> items = ['john', 'tony', 'luck', 'o', 'mIssissippi'] >>> list(replace_vowel(items)) ['j-hn', 't-ny', 'l-ck', '-', 'm-ss-ss-pp-']