Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

How does HRM affect all managers?

Answered: 1 week ago