Ad

Correction of the algorithme

Code
Diff
  • import re
    
    def count(text: str) -> int:
        pattern = r"[aeiouyAEIOUY]"
    
         # Find all vowel matches in the string/text
        matches = re.findall(pattern, text)
    
        # Return the number of vowels
        return len(matches)
    • import re
    • def count(text: str) -> int:
    • ctr = 0
    • vowels = ['a', 'e', 'i', 'o', 'u']
    • for letter in text:
    • if letter.lower() in vowels:
    • ctr += 1
    • pattern = r"[aeiouyAEIOUY]"
    • # Find all vowel matches in the string/text
    • matches = re.findall(pattern, text)
    • return ctr
    • # Return the number of vowels
    • return len(matches)