Correction of the algorithme
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 = 0vowels = ['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)
import re import codewars_test as test from solution import count # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(count('123'), 0) test.assert_equals(count('hi'), 1) test.assert_equals(count('seraph'), 2) test.assert_equals(count('codewarz'), 3) test.assert_equals(count('MissISsIpPi'), 4)
- import re
- import codewars_test as test
- from solution import count
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- test.assert_equals(count('123'), 0)
- test.assert_equals(count('hi'), 1)
- test.assert_equals(count('seraph'), 2)
- test.assert_equals(count('codewarz'), 3)
- test.assert_equals(count('MissISsIpPi'), 4)