From 75d5ca41fef805aea55d755be9d06f81555ead08 Mon Sep 17 00:00:00 2001 From: Jamal Laqdiem Date: Thu, 2 Apr 2026 11:58:04 +0100 Subject: [PATCH 1/2] feat: Complete the cowsay exercise. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3c3629e64..671215ddc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.venv From c4c0576b868bb000f52e1a9d49cc0f3b266e4b3c Mon Sep 17 00:00:00 2001 From: Jamal Laqdiem Date: Thu, 2 Apr 2026 11:58:20 +0100 Subject: [PATCH 2/2] feat: Complete the cowsay exercise. --- implement-cowsay/cow.py | 22 ++++++++++++++++++++++ implement-cowsay/requirements.txt | 1 + 2 files changed, 23 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 000000000..99ba593dc --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,22 @@ +import cowsay +import argparse + +# 1. Fetch the animals from the library +list_of_animals = cowsay.char_names + +# 2. Setup the Parser, I'm building a program cowsay that to do(description). +parse = argparse.ArgumentParser(prog='cowsay', description='make animals say things') +parse.add_argument('message', nargs='+', help='The message to say') + +parse.add_argument('--animal', choices=list_of_animals, default='cow', help='The animal to use') + +args = parse.parse_args() + +# Combining the words into a single string +message_text = " ".join(args.message) + +# we call the draw_function and we use getattr because args.animal is a string, and we need a function instead. +draw_function = getattr(cowsay, args.animal) + +# 4. call and execute. +draw_function(message_text) diff --git a/implement-cowsay/requirements.txt b/implement-cowsay/requirements.txt new file mode 100644 index 000000000..9e0634373 --- /dev/null +++ b/implement-cowsay/requirements.txt @@ -0,0 +1 @@ +cowsay==6.1