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

chore: Refactor Animal class and its subclasses #1204

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

AversArthur
Copy link

No description provided.

app/main.py Outdated
print("The slippers delivered!")


def feed_animals(animals: list) -> None:

Choose a reason for hiding this comment

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

Suggested change
def feed_animals(animals: list) -> None:
def feed_animals(animals: list[Animal]) -> None:

app/main.py Outdated

def feed_animals(animals: list) -> None:
total_food = 0
for animal in animals:

Choose a reason for hiding this comment

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

use list comprehension

app/main.py Outdated
return total_food


elephant = Animal("Elephant", 100)

Choose a reason for hiding this comment

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

delete this code

app/main.py Outdated

def feed_animals(animals: list[Animal]) -> None:
total_food = sum([animal.feed() for animal in animals])
return total_food

Choose a reason for hiding this comment

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

Suggested change
return total_food
return sum(animal.feed() for animal in animals)

app/main.py Outdated


def feed_animals(animals: list[Animal]) -> None:
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.

Suggested change
return sum([animal.feed() for animal in animals])
return sum(animal.feed() for animal in animals)

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