Python Practice › String Programs › Program 50
Split a string on vowels
Write a Python program to split a string wherever a vowel appears.
Input
"qwerty"
Output
['qw', 'rty'] pr gr mm ng
Approach
re.split("[aeiou]", text)removes the vowels and splits there.
Solution
import reprint(re.split(r"[aeiouAEIOU]", "qwerty"))print(" ".join(re.split(r"[aeiou]", "programming")))Output
['qw', 'rty'] pr gr mm ng
Learn the concept
New to this topic? Read the lesson, then come back.