From e85886fbc11d03436922b05a28f24fa1f2af1b7e Mon Sep 17 00:00:00 2001 From: sheetalkharab Date: Wed, 6 Aug 2025 11:17:31 +0100 Subject: [PATCH] cow.py file and requirement .txt file --- implement-cowsay/cow.py | 36 ++++++++++++++++++++++++++++++ implement-cowsay/requirements.txt | Bin 0 -> 18 bytes 2 files changed, 36 insertions(+) create mode 100644 implement-cowsay/cow.py create mode 100644 implement-cowsay/requirements.txt diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py new file mode 100644 index 00000000..19ef2711 --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,36 @@ +import cowsay +import argparse + +# give a list of supported animal from cowsay +list_of_choices = cowsay.char_names + + +# to set argument parser +parser = argparse.ArgumentParser( + prog="cowsay", + description="Make animals say things", +) + +# to pass optional flag with restricted choice :--animal +parser.add_argument( + "--animal", + choices=list_of_choices, + default="cow", + help="The animal to be saying things." +) + +# to add positional argument +parser.add_argument( + "message", + nargs="*", + default="", + help="message to say") + +# To parse command line input +args = parser.parse_args() + +message_text = " ".join(args.message) + +# to print the result with selected element +print(cowsay.get_output_string(str(args.animal), message_text)) + diff --git a/implement-cowsay/requirements.txt b/implement-cowsay/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..1f8ead5813a76b72271fa3f857cdc721e119bc93 GIT binary patch literal 18 ZcmezWFPR~qp`4+ZA(5eyftP`c0RTT(1gii5 literal 0 HcmV?d00001