Python Practice › List Programs › Program 22
Words that contain vowels
Write a Python program to get the words of a string that contain at least one vowel.
Input
"www Student ppp are qqqq learning Python vvv"
Output
['Student', 'are', 'learning', 'Python']
Approach
- Keep words where
anycharacter is a vowel.
Solution
text = "www Student ppp are qqqq learning Python vvv"print([w for w in text.split() if any(ch in "aeiouAEIOU" for ch in w)])Output
['Student', 'are', 'learning', 'Python']
Learn the concept
New to this topic? Read the lesson, then come back.