Count the vowels
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
This one builds on a lesson you haven't finished yet. Do that lesson first:
Python Basics · Functions →
Count the vowels
Count how many characters of a string are vowels — a, e, i, o, u — treating capitals and lowercase the same.
Lowercase the string first with s.lower() so you only have five letters to check. The expression ch in "aeiou" is True when ch is one of them.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
Write count_vowels(s): return how many letters in s are vowels (a, e, i, o, u), case-insensitive.
Click Run to see the output here.