Day 39 of 100 Days of Python
Practising Recursion
1
2
3
4
5
6
7
8
9
10
11
# counting vowel in string
def count_vowel(str):
if str =="":
return 0
if str[0] == 'a' or str[0] == 'e' or str[0] == 'i' or str[0] == 'o' or str[0] == 'u':
return 1 + count_vowel(str[1:])
else:
return count_vowel(str[1:])
print(count_vowel("camera"))
This post is licensed under CC BY 4.0 by the author.