Python Practice › String Programs › Program 66
Count and show vowels
Write a Python program to count and display the vowels in a string.
Input
"welcome to Sqatools"
Output
['e', 'o', 'e', 'o', 'a', 'o', 'o'] 7
Approach
- Collect the vowels in a list.
Solution
text = "welcome to Sqatools"vowels = [ch for ch in text if ch.lower() in "aeiou"]print(vowels, len(vowels))Output
['e', 'o', 'e', 'o', 'a', 'o', 'o'] 7
Learn the concept
New to this topic? Read the lesson, then come back.