Python Practice › String Programs › Program 50

Split a string on vowels

EasyString Programs · 50 of 106

Write a Python program to split a string wherever a vowel appears.

Advertisement
Input
"qwerty"
Output
['qw', 'rty']
pr gr mm ng

Approach

  1. re.split("[aeiou]", text) removes the vowels and splits there.

Solution

Python
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.

More string programs

← All 106 String Programs

Leave a Comment