File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,15 @@ def main():
27
27
28
28
args = get_args ()
29
29
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
+
31
39
print (f'Ahoy, Captain, { article } { word } off the larboard bow!' )
32
40
33
41
# --------------------------------------------------
Original file line number Diff line number Diff line change 1
- #!/usr/bin/env python3
1
+ #!/usr/bin/env python3
2
2
"""tests for crowsnest.py"""
3
3
4
4
import os
@@ -47,7 +47,7 @@ def test_consonant_upper():
47
47
48
48
for word in consonant_words :
49
49
out = getoutput (f'{ prg } { word .title ()} ' )
50
- assert out .strip () == template .format ('a ' , word .title ())
50
+ assert out .strip () == template .format ('A ' , word .title ())
51
51
52
52
53
53
# --------------------------------------------------
@@ -64,5 +64,5 @@ def test_vowel_upper():
64
64
"""octopus -> an Octopus"""
65
65
66
66
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 ())
You can’t perform that action at this time.
0 commit comments