QuickSnip LogoA light blue logo with a thunderbolt in bracketsQuickSnip

Count Vowels

Counts the number of vowels in a string.

  • string
  • vowels
  • count

Code

def count_vowels(s):
    vowels = 'aeiou'
    return len([char for char in s.lower() if char in vowels])

Usage

count_vowels('hello') # Returns: 2