Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed69f2d

Browse files
committed
Updated test and code for matching case for article.
1 parent 29d2b6b commit ed69f2d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

02_crowsnest/crowsnest.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ def main():
2727

2828
args = get_args()
2929
word = args.word
30-
article = 'an' if word[0].lower() in 'aeiou' else 'a'
30+
31+
"""Original solution"""
32+
#article = 'an' if word[0].lower() in 'aeiou' else 'a'
33+
34+
if word[0].islower():
35+
article = 'an' if word[0] in 'aeiou' else 'a'
36+
else:
37+
article = 'An' if word[0] in 'AEIOU' else 'A'
38+
3139
print(f'Ahoy, Captain, {article} {word} off the larboard bow!')
3240

3341
# --------------------------------------------------

02_crowsnest/test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env python3
22
"""tests for crowsnest.py"""
33

44
import os
@@ -47,7 +47,7 @@ def test_consonant_upper():
4747

4848
for word in consonant_words:
4949
out = getoutput(f'{prg} {word.title()}')
50-
assert out.strip() == template.format('a', word.title())
50+
assert out.strip() == template.format('A', word.title())
5151

5252

5353
# --------------------------------------------------
@@ -64,5 +64,5 @@ def test_vowel_upper():
6464
"""octopus -> an Octopus"""
6565

6666
for word in vowel_words:
67-
out = getoutput(f'{prg} {word.upper()}')
68-
assert out.strip() == template.format('an', word.upper())
67+
out = getoutput(f'{prg} {word.title()}')
68+
assert out.strip() == template.format('An', word.title())

0 commit comments

Comments
 (0)