Educatifu
Open menu

Count the Vowels

Easystrings

Count how many vowels a string contains. Vowels are a, e, i, o, u, in either upper or lower case.

Input

A single line containing the string s.

Output

A single integer: the number of vowels in s.

Examples

Example 1

Input
hello
Output
2

e and o are vowels — 2.

Example 2

Input
sky
Output
0

No vowels — 0.

Example 3

Input
AEIOU
Output
5

Upper-case vowels count too — 5.

Constraints

  • 1 <= length of s <= 10^4

Hints

Reveal hint 1

Walk through each character and check whether it is one of the ten vowel characters (five letters in two cases).

Reveal hint 2

Put the vowels in a set/string like "aeiouAEIOU" and count characters that belong to it.

Reference solution (spoiler — try it yourself first)

Approach

Iterate over the characters and count those that appear in the vowel set (both cases).

s = input()
print(sum(1 for c in s if c in "aeiouAEIOU"))

← All practice problems

Bring us the problem, not a perfect specification

Tell us what needs to change, who it affects and any important deadline. We will review the context and reply with useful next questions.

  1. 01Share contextDescribe the workflow, constraint or risk.
  2. 02Clarify togetherWe identify missing facts and useful options.
  3. 03Choose a startAgree a focused assessment or delivery step.
Start a conversation