0

Can I count how many vowels are in a word?

If someone types a word like education, how do I count and print how many vowels it has? (Example: education → 5 vowels)

29th Jul 2025, 10:51 PM
SAIFULLAHI KHAMISU
SAIFULLAHI KHAMISU - avatar
2 Réponses
+ 3
First let's create a variable string for the vowels we are seeking to count... vowels = "aeiouAEIOU" Now let's walk through the for loop ( for char in input() ) and check rather ( char in vowels ) In doing so we are counting the vowels and asking for the sum total of vowels we found. print(sum(char in vowels for char in input()))
29th Jul 2025, 11:56 PM
BroFar
BroFar - avatar
+ 2
Hi, Before asking for help, please provide an example of what you tried. These exercises are for you to learn, and its impossible to learn if you don't try. If you are really completely stuck, here is the idea of how that works: We iterate through the word and check every character against a vowel. if the current character is in "eiouaEIOUA" (to cover both lower and upper case), we increment the counter. If after that u are still not sure how to code it, its a good idea to retake relevant course content.
29th Jul 2025, 11:08 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar