How to create a translation table to replace vowels in Python

1 Answer

0 votes
# vowels = aeiou

# Create translation table to replace vowels
replace_vowels = str.maketrans({97: '*', 101: '*', 105: '*', 111: '*', 117: '*'})
text = "Hello, how are you?"

result = text.translate(replace_vowels)

print(result) 



'''
run:

H*ll*, h*w *r* y**?

'''

 



answered Mar 8 by avibootz

Related questions

2 answers 232 views
2 answers 185 views
185 views asked Jun 22, 2016 by avibootz
1 answer 129 views
1 answer 126 views
2 answers 170 views
1 answer 136 views
...