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

Skip to content

Commit 29d2b6b

Browse files
committed
Refactor crowsnest.py
1 parent ac90379 commit 29d2b6b

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

02_crowsnest/crowsnest.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
Author : Ryan Alcoran <r.alcoran>
44
Date : 2020-11-15
5-
Purpose: Rock the Casbah
5+
Purpose: Crow's Nest
66
"""
77

88
import argparse
@@ -21,28 +21,14 @@ def get_args():
2121
help='A word')
2222
return parser.parse_args()
2323

24-
# --------------------------------------------------
25-
def is_vowel(char):
26-
"""Check if character is a vowel"""
27-
28-
ch = char.lower()
29-
if(ch=='a' or ch=='e' or ch=='i' or ch=='o' or ch=='u'):
30-
return True
31-
else:
32-
return False
33-
3424
# --------------------------------------------------
3525
def main():
3626
"""Make a jazz noise here"""
3727

3828
args = get_args()
3929
word = args.word
40-
article = ''
41-
if (is_vowel(word[0]) == True):
42-
article = 'an '
43-
else:
44-
article = 'a '
45-
print('Ahoy, Captain, '+ article + word + ' off the larboard bow!')
30+
article = 'an' if word[0].lower() in 'aeiou' else 'a'
31+
print(f'Ahoy, Captain, {article} {word} off the larboard bow!')
4632

4733
# --------------------------------------------------
4834
if __name__ == '__main__':

0 commit comments

Comments
 (0)