File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 11import argparse
2- import cowsay
2+ import cowsay #to do the ascii art with animals
33
44def main ():
5+ #getlistof animals within cowsay
56 animals = cowsay .char_names
7+ #create a parser for command line argument
68 parser = argparse .ArgumentParser (
79 description = "Make animals say things!"
810 )
@@ -12,8 +14,11 @@ def main():
1214 default = 'cow' ,
1315 help = 'The animal to be saying things (default: cow)'
1416 )
17+ #argument for the message
1518 parser .add_argument ('message' ,nargs = '+' ,help = 'The message to say' )
19+ #to parse the arguments from the command line
1620 args = parser .parse_args ()
21+ #the messageword into a single string
1722 text = ' ' .join (args .message )
1823
1924 try :
@@ -22,6 +27,6 @@ def main():
2227 except cowsay .CowsayError as e :
2328 print (f"Error: { e } " )
2429 exit (1 )
25-
30+ #run main function only if this script is run directly
2631if __name__ == '__main__' :
2732 main ()
You can’t perform that action at this time.
0 commit comments