python remove vowels from string
Python[Edit]
+
0
-
0
python remove vowels from string
1 2 3 4 5 6 7 8 9 10 11 12 13 14def remove_vowels(string): vowels = ['A', 'E', 'I', 'O', 'U', 'Y'] result = [letter for letter in string if letter.upper() not in vowels] return ''.join(result) # Usage example: text = 'Example text...' print(remove_vowels(text)) # 'xmpl txt...' # More examples: print(remove_vowels('AeIoUy')) # '' print(remove_vowels('Hello World!')) # 'Hll Wrld!'
[Edit]
+
0
-
0
python remove vowels from string
1 2 3 4 5 6 7 8 9 10import re def remove_vowels(string): return re.sub(r'[aeiouy]', '', string, flags=re.IGNORECASE) # Usage example: text = 'Example text...' print(remove_vowels(text)) # 'xmpl txt...'