Skip to content

Commit bc0b217

Browse files
author
joy
committed
kyclark#2 joy.y
1 parent 7d819f3 commit bc0b217

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

02_crowsnest/crowsnest.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Author : NowHappy <[email protected]>
4+
Date : 2021-09-28
5+
Purpose: Rock the Casbah
6+
"""
7+
8+
import argparse
9+
10+
11+
# --------------------------------------------------
12+
def get_args():
13+
"""Get command-line arguments"""
14+
15+
parser = argparse.ArgumentParser(
16+
description="Crow's Nest -- choose the correct article",
17+
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
18+
19+
parser.add_argument('word',
20+
metavar='word',
21+
help='A word')
22+
23+
return parser.parse_args()
24+
25+
26+
# --------------------------------------------------
27+
def main():
28+
"""Make a jazz noise here"""
29+
30+
args = get_args()
31+
word = args.word
32+
char = word[0].lower()
33+
article = 'an' if char in 'aeiou' else 'a'
34+
print(f'Ahoy, Captain, {article} {word} off the larboard bow!')
35+
36+
37+
# --------------------------------------------------
38+
if __name__ == '__main__':
39+
main()

0 commit comments

Comments
 (0)