Skip to content
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

Add feed animals solution #1279

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

charmheroku
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on the task! 🎉 You've met the core requirements and your code is functional. However, there are some minor improvements that can be made to make your code more Pythonic and readable. Keep pushing to refine your coding skills. Happy coding! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

print(f"Eating {self.appetite} food points...")
self.is_hungry = False
return self.appetite
return 0

Choose a reason for hiding this comment

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

You don't need to use an else statement here. According to the checklist, it's better to write it like this:

python
if self.is_hungry:
print(f"Eating {self.appetite} food points...")
self.is_hungry = False
return self.appetite
return 0


This way, the code is easier to read and understand.


def feed_animals(animals: list) -> int:

return sum(animal.feed() for animal in animals)

Choose a reason for hiding this comment

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

You are using a for loop in a situation where you could use a list comprehension. According to the checklist, it's better to replace the for loop with a list comprehension. Here's how you could do it:

return sum(animal.feed() for animal in animals)

This way, the code is shorter and more Pythonic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants