Skip to content

Conversation

Faithy4444
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@Faithy4444 Faithy4444 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 4, 2025
@illicitonion illicitonion changed the title Cape Town| 25-SDC-July | Faith Muzondo | Sprint 3| Implement cowsay Cape Town| 25-SDC-July | Faith Muzondo | Sprint 4| Implement cowsay Aug 6, 2025
@DaryaShirokova DaryaShirokova added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 17, 2025
Copy link

@DaryaShirokova DaryaShirokova left a comment

Choose a reason for hiding this comment

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

Please make sure only files you authored are added to the pr (one main file and one requirements.txt file in this case).

parser.add_argument('message', type=str, help= 'please enter a message')
arg = parser.parse_args()

valid_animals = cowsay.char_names

Choose a reason for hiding this comment

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

There is a way to validate the lsit of animals though argparse directly (check out choices argument).

Copy link
Author

Choose a reason for hiding this comment

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

I have fixed this and also removed the other files

Choose a reason for hiding this comment

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

Now I think it doesn't validate them at all? Could you please test this out?

Please also validate on the examples in readme:

python3 cow.py Grass, delicious.
python3 cow.py --animal turtle Fish are cool!
python3 cow.py --animal fish Turtles are cool too! // fish is not a valid arg

@DaryaShirokova DaryaShirokova added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 17, 2025
@@ -0,0 +1,18 @@
{

Choose a reason for hiding this comment

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

There are still some extra files that should not be committed, and README should not be removed, could you please have another look?

Copy link
Author

Choose a reason for hiding this comment

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

my Apologies. the files were in my main branch thats why I was missing them. I have made changes and also validated using argparse

parser.add_argument('message', type=str, help= 'please enter a message')
arg = parser.parse_args()

valid_animals = cowsay.char_names

Choose a reason for hiding this comment

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

Now I think it doesn't validate them at all? Could you please test this out?

Please also validate on the examples in readme:

python3 cow.py Grass, delicious.
python3 cow.py --animal turtle Fish are cool!
python3 cow.py --animal fish Turtles are cool too! // fish is not a valid arg


parser = argparse.ArgumentParser(description="displays cowsay charactor with given arguments")
parser.add_argument('animal', type=str, choices=cowsay.char_names, default="cow", help= 'please enter a valid animal')
parser.add_argument('message', type=str, help= 'please enter a message')

Choose a reason for hiding this comment

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

Could you please try to run the commands exactly as described in readme? For example, that's what I see (I replaced cow.py with main.py to match your naming):

python3 main.py Grass, delicious.
usage: main.py [-h] {beavis,cheese,cow,daemon,dragon,fox,ghostbusters,kitty,meow,miki,milk,octopus,pig,stegosaurus,stimpy,trex,turkey,turtle,tux} message
main.py: error: argument animal: invalid choice: 'Grass,' (choose from 'beavis', 'cheese', 'cow', 'daemon', 'dragon', 'fox', 'ghostbusters', 'kitty', 'meow', 'miki', 'milk', 'octopus', 'pig', 'stegosaurus', 'stimpy', 'trex', 'turkey', 'turtle', 'tux')

You may want to check nargs for the message arg :) https://docs.python.org/3/library/argparse.html#nargs

You can also check on positional arguments : https://docs.python.org/3/library/argparse.html (animal should be specified via --animal)

Let me know if you have any questions!

@DaryaShirokova DaryaShirokova added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 24, 2025

msg = " ".join(arg.message)
animal_func = getattr(cowsay, arg.animal)
print(animal_func(msg))

Choose a reason for hiding this comment

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

Note: you don't need to use print here as your animal_func already prints the message. Because of the extra print you get None at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complete Volunteer to add when work is complete and all review comments have been addressed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants