-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount_au.py
More file actions
41 lines (26 loc) · 750 Bytes
/
Copy pathcount_au.py
File metadata and controls
41 lines (26 loc) · 750 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
37
38
39
40
41
import pytest
def count_au(s):
'''
Counts the number of "a"s and "u"s in a string, both capitalized and lowercase.
'''
if type(s) != str:
return 0
count = 0
for item in s:
if item == 'a' or item == 'A' or item == 'u' or item == 'U':
count += 1
return count
def test_count_au_0():
assert(count_au(42)==0)
def test_count_au_1():
assert(count_au('mai')==1)
def test_count_au_2():
assert(count_au('MAYA')==2)
def test_count_au_3():
assert(count_au('maui')==2)
def test_count_au_4():
assert(count_au('moana')==2)
def test_count_au_5():
assert(count_au('Auckland')==3)
def test_count_au_6():
assert(count_au('Meeseeks')==0)