-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Solution #918
base: master
Are you sure you want to change the base?
Solution #918
Conversation
app/main.py
Outdated
def __add__(self, other: Distance | int | float) -> Distance: | ||
if isinstance(other, Distance): | ||
return Distance( | ||
km=self.km + other.km | ||
) | ||
if isinstance(other, (int, float)): | ||
return Distance( | ||
km=self.km + other | ||
) |
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 __add__(self, other: Distance | int | float) -> Distance: | |
if isinstance(other, Distance): | |
return Distance( | |
km=self.km + other.km | |
) | |
if isinstance(other, (int, float)): | |
return Distance( | |
km=self.km + other | |
) | |
def __add__(self, other: Distance | int | float) -> Distance: | |
if isinstance(other, Distance): | |
return Distance( | |
km=self.km + other.km | |
) | |
return Distance( | |
km=self.km + other | |
) |
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.
Fix this everywhere. As you defined that function gets only Distance / int / float -> you don't need to use second if.
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.
Good job
No description provided.