Skip to content

Count Vowels

Background

Counting specific characters in a string is a fundamental text processing task. Vowels (a, e, i, o, u) are often of interest in linguistic analysis.

Task

Write a function count_vowels(s: str) -> int that returns the number of vowels (both uppercase and lowercase) in a given string.

Specifications

  • Input: A string s of arbitrary length.
  • Output: An integer representing the total count of vowels ('a', 'e', 'i', 'o', 'u' case-insensitive).

Constraints

  • Do not use input() or print().
  • The string may contain non-alphabetic characters.

Example

>>> count_vowels("Hello World")
3
>>> count_vowels("AEIOU")
5

Instructions

Implement the function in solution.py.

Solve Online | Leer en Español