-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
added solution #913
base: master
Are you sure you want to change the base?
added solution #913
Conversation
app/main.py
Outdated
name = "{Name: " + str(self.name) | ||
health = ", Health: " + str(self.health) | ||
hidden = ", Hidden: " + str(self.hidden) + "}" | ||
return name + health + hidden |
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.
explicitly defining the string that should be returned will improve the readability
Just use f-strings and parentheses to split into lines
app/main.py
Outdated
class Carnivore(Animal): | ||
|
||
@staticmethod | ||
def bite(animal: Union[Herbivore, Carnivore]) -> 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.
You can use Animal class for annotations here, it will include Herbivore, Carnivore and other classes, that could be created in the future
app/main.py
Outdated
|
||
@staticmethod | ||
def bite(animal: Union[Herbivore, Carnivore]) -> None: | ||
if animal.hidden is False and isinstance(animal, Herbivore): |
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.
You can use not
in the condition
if not animal.hidden
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.
Great 💪
No description provided.