Codington
0 of 6 problems solved • 0%

Exercise prompt

Count Vowels

A for loop can visit each character of a string. The expression ch in 'xyz' checks whether that string contains the character.

Example

A signal decoder picks out punctuation as it reads a message.

message = "Wait, go!" marks = "" for char in message: if char in ",!?": marks += char print(marks) # ,!

Each pass sees one character, so a repeated mark would be collected twice. For a count, update a number whenever a character qualifies.

Your task

Complete count_vowels(text). Count every occurrence of a, e, i, o, or u, ignoring case. All other characters contribute zero.

count_vowels("Queue!") # 4