-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex2.py
More file actions
36 lines (28 loc) · 721 Bytes
/
Copy pathex2.py
File metadata and controls
36 lines (28 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
__author__ = 'Administrator'
def count_vowels(word):
j = 0
for i in word:
if i in 'AaEeIiOoUu':
j += 1
return j
print(count_vowels('hello'))
print('-------------------------')
def count_consonants(word):
k = 0
for i in word:
if i not in 'AaEeIiOoUu':
k += 1
return k
print(count_consonants('hello'))
print('-----------////--------------')
def count_letters(word):
""" (str) -> int
Return the number of letters in word.
>>> count_letters('hello')
5
>>> count_letters('bonjour')
7
"""
# Write the one-line function body that belongs here.
return count_vowels(word) + count_consonants(word)
print(count_letters('hello'))