Files
30-seconds-of-code/snippets/countVowels.md
Rohit Tanwar 1cb811f877 Update typo.md
2018-01-09 18:29:43 +05:30

332 B

countVowels

Retuns number of vowels in provided string.

Use a regular expression to count the number of vowels (A, E, I, O, U) in a string.

import re


def countVowels(str):
    return len(len(re.findall(r'[aeiou]', str, re.IGNORECASE)))

countVowels('foobar') # 3
countVowels('gym') # 0