Skip to content

Commit 073ce24

Browse files
committed
solution chapter 2:
1 parent 0245de0 commit 073ce24

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tex2pdf*
1111
.coverage
1212
.idea
1313
.vscode
14-
02_crowsnest/crowsnest.py
14+
#02_crowsnest/crowsnest.py
1515
03_picnic/picnic.py
1616
04_jump_the_five/jump.py
1717
05_howler/howler.py

‎02_crowsnest/crowsnest.py‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Author : fededc88 <fededc88@localhost>
4+
Date : 2024-04-10
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 -- chose 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+
33+
article = 'an' if word[0].lower() in 'aeiou' else 'a'
34+
35+
print(f'Ahoy, Captain, {article} {word} off the larboard bow!')
36+
37+
38+
# --------------------------------------------------
39+
if __name__ == '__main__':
40+
main()

0 commit comments

Comments
 (0)