Question
The parents dictionary in the final.py file is a dictionary whose keys are strings (names) and whose values are lists of strings (names). For example:
The parents dictionary in the final.py file is a dictionary whose keys are strings (names) and whose values are lists of strings (names). For example:
>>> parents['Mark Zuckerberg']
['Edward Zuckerberg', 'Karen Zuckerberg']
The parents of Mark Zuckerberg (the CEO of Facebook) are named Edward Zuckerberg and Karen Zuckerberg.
Complete the ancestors function, so that it returns a list of the ancestors of a person, including the person's parents, grandparents, great grandparents, and so on (assuming those ancestors are listed in the dictionary). Although the parents dictionary as it stands only goes back as far as two of Mark's great grandparents, you should assume that the ancestry information of a person might continue for an arbitrary number of generations.
When completed, here are some of examples of correct output:
>>> ancestors('Mark Zuckerberg')
['Edward Zuckerberg', 'Karen Zuckerberg', 'Miriam Hollnder', 'Jack Zuckerberg', 'Minnie Wiesenthal', 'Max Zuckerberg'] >>> ancestors('Edward Zuckerberg') ['Miriam Hollnder', 'Jack Zuckerberg', 'Minnie Wiesenthal', 'Max Zuckerberg'] >>> ancestors('Jack Zuckerberg') ['Minnie Wiesenthal', 'Max Zuckerberg']
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started