File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+ """
3
+ Author : Sunil Nahata
4
+ Date : 2024-03-21
5
+ Purpose: Choose the article
6
+ """
7
+
8
+ import argparse
9
+
10
+
11
+ # --------------------------------------------------
12
+ def get_args ():
13
+ """Get command-line arguments"""
14
+
15
+ parser = argparse .ArgumentParser (
16
+ description = 'Choose the article' ,
17
+ formatter_class = argparse .ArgumentDefaultsHelpFormatter )
18
+
19
+ parser .add_argument ('word' ,
20
+ metavar = 'word' ,
21
+ help = 'The thing we see' )
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
+ article = ""
33
+
34
+ if word [0 ].lower () in 'aeiou' :
35
+ article = "an"
36
+ else :
37
+ article = "a"
38
+
39
+ print (f"Ahoy, Captain, { article } { word } off the larboard bow!" )
40
+
41
+ # --------------------------------------------------
42
+ if __name__ == '__main__' :
43
+ main ()
You can’t perform that action at this time.
0 commit comments