Python Practice › String Programs › Program 32
Count vowels
Write a Python program to count the vowels in a string.
Input
"I am learning python"
Output
6
Approach
- Count characters that are in “aeiou”, ignoring case.
Solution
text = "I am learning python"print(sum(1 for ch in text.lower() if ch in "aeiou"))Output
6
Learn the concept
New to this topic? Read the lesson, then come back.