Skip to content

LONDON | DONARA BLANC | COWSAY PYTHON | SPRINT 4 #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions implement-cowsay/cow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import cowsay

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I were to check out this code, how would python find cowsay? What has been covered in the course about adding libraries to your code? Is there another file you need to edit or add?

The rest of your code is fine - so the contents of cow.py - but you are missing a vital element to make the whole thing work.

import argparse

parser = argparse.ArgumentParser(description= "animals talking gibberish")

parser.add_argument(

"--animal",
choices=cowsay.char_names,
help="an animal is talking"
)

parser.add_argument(
"message",
nargs="+",
help="msg to say"
)

args = parser.parse_args()

text = " ".join(args.message)

animal = args.animal or "cow"

output = cowsay.get_output_string(animal, text)
print(output)