How to Remove All Vowels from a String
How to Remove All Vowels from a String
How to Remove All Vowels from a String
I need to remove all vowels (a, e, i, o, u) from a string. How can I do this?
solveurit24@gmail.com Changed status to publish February 16, 2025
You can use a list comprehension to filter out vowels.
Code Example:
def remove_vowels(string):
return ''.join([char for char in string if char.lower() not in {'a', 'e', 'i', 'o', 'u'}])
print(remove_vowels("Hello World")) # Output: "Hll Wrld"
This function returns a new string with all vowels removed.
solveurit24@gmail.com Changed status to publish February 16, 2025