-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: master
Are you sure you want to change the base?
Conversation
app/main.py
Outdated
print("The slippers delivered!") | ||
|
||
|
||
def feed_animals(animals: list) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this code
…alculating total food points
app/main.py
Outdated
|
||
def feed_animals(animals: list[Animal]) -> None: | ||
total_food = sum([animal.feed() for animal in animals]) | ||
return total_food |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return sum([animal.feed() for animal in animals]) | |
return sum(animal.feed() for animal in animals) |
… calculating total food points
No description provided.