Tuesday, February 15, 2022

Vowel Count Python Codewars

 

Return the number (count) of vowels in the given string.

We will consider a, e, i, o, u as vowels for this Kata (but not y).

The input string will only consist of lower case letters and/or spaces.


def get_count(sentence):
    vowels = 'aeiou'
    count_vowels = 0
    for x in sentence:
        if x in vowels:
            count_vowels += 1
    return count_vowels

def get_count(sentence):
    return sum(c in 'aeiou' for c in sentence)

Training on Vowel Count | Codewars



Related Posts


No comments :

Post a Comment