Skip to content

Commit c2d9fc9

Browse files
committed
Refactor animal function retrieval and message display in cowsay implementation
1 parent aacddf6 commit c2d9fc9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

implement-cowsay/cow.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ def main():
1717
# Combine the message into a single string
1818
message = " ".join(args.message)
1919

20-
# Get the animal function dynamically
21-
animal_function = getattr(cowsay, args.animal, cowsay.cow)
20+
# Get the animal function from the library mapping
21+
animal_function = cowsay.char_funcs[args.animal]
2222

23-
# Print the message using the selected animal
24-
print(animal_function(message))
23+
# Display the message using the selected animal
24+
animal_function(message)
2525

2626
if __name__ == "__main__":
2727
main()

0 commit comments

Comments
 (0)