Python bootcamp · Lab 13

Count the vowels

easyStrings10 minLesson: String Methods

Read the question, write Python on the right, then Run or Check.

QuestionHint and solution stay closed until you open them

Read one word and print how many vowels (a, e, i, o, u) it contains.

Count both uppercase and lowercase vowels — normalise the case first so you only check one set.

Input. One line: a word.

Output. One integer: the vowel count.

Examples

Example 1 — o, a, i.
Input
Programming
Output
3
Example 2 — y does not count here.
Input
sky
Output
0
Hint
  1. Lowercase the word with .lower() so "A" and "a" are treated the same.
  2. sum(1 for c in word if c in "aeiou") counts them in one pass.
Show correct code

Peek only after you have tried. You can still Check your own version.

word = input().strip()
print(sum(1 for c in word.lower() if c in "aeiou"))
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.