Newer
Older
bth_py_exercises / 1.09 / count_vowels.py
"""
Exercise 1.9 - Count Vowels
"""


#  Copyright (c) 2021. Pascal Syma. All rights reserved.

def count_vowels(string: str) -> int:
    """
    Count the amount of vowels (a, e, i, o ,u) in a string.
    :param string: Input string
    :return: Amount of vowels
    """
    vowels = 'aeiou'
    count = 0
    for char in string:
        if char in vowels:
            count += 1

    return count


if __name__ == '__main__':
    print(f'{count_vowels("elephant") = }')
    print(f'{count_vowels("apple") = }')