blob: 7376feab26b290d7a18a56d1632188af17d0a2a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
def count_vowels(test_str):
res = 0
vow_list = ['a', 'e', 'i', 'o', 'u']
for idx in range(1, len(test_str) - 1):
if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list):
res += 1
if test_str[0] not in vow_list and test_str[1] in vow_list:
res += 1
if test_str[-1] not in vow_list and test_str[-2] in vow_list:
res += 1
return (res)
|