London | 25-SDC-Nov | Jesus del Moral | Sprint 5| Prep Exercises#295
London | 25-SDC-Nov | Jesus del Moral | Sprint 5| Prep Exercises#295delmorallopez wants to merge 3 commits into
Conversation
4cc7c30 to
294b028
Compare
| # - Methods support inheritance | ||
| # - Better organization | ||
| # - Better organization | ||
| # - Methods enable polymorphism |
| def print_family_tree(person: Person) -> None: | ||
| print(person.name) | ||
| for child in person.children: | ||
| print(f"- {child.name} ({child.age})") |
There was a problem hiding this comment.
Can this print grandchildren recursively?
There was a problem hiding this comment.
I have made print_family_tree recursive, so it prints children, grandchildren, great-grandchildren...
There was a problem hiding this comment.
You might want to change the validation to allow for reentry if the input was invalid, rather than exiting immediately
There was a problem hiding this comment.
I have modify the code, crating a while loop, each input is wrapped in a while True loop. Only break from the loop when a valid value is entered. Invalid entries print an error to stderr but don’t exit, so the user can retry.
01aed45 to
40a13c5
Compare
|
Good work on these tasks! |
|
Closing PR because the SDC run has finished. Feel free to re-open if you're still working on it. |
Preparation exercise from Sprint5