Python Practice › List Programs › Program 22

Words that contain vowels

EasyList Programs · 22 of 100

Write a Python program to get the words of a string that contain at least one vowel.

Advertisement
Input
"www Student ppp are qqqq learning Python vvv"
Output
['Student', 'are', 'learning', 'Python']

Approach

  1. Keep words where any character is a vowel.

Solution

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

More list programs

← All 100 List Programs

Leave a Comment