Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is the code i wrote so far. But, when it computes differently and it was wrong. How do i write the code for this
This is the code i wrote so far. But, when it computes differently and it was wrong. How do i write the code for this python problem?
(note: i have only learned up to tuples)
Ancestors Function Name: ancestors() Parameters: list of names ( list ), surname (str) Returns: matching names ( list) Description: Seeing people participate in mail-in DNA ancestry tests lately, you have decided you want to participate, but you would rather save money and code your own test. Write a function that takes in a list of names and a specific surname to search for. Return a list of the first names of all the names in the original list that have the correct surname AND do not have middle names. There should be no repeats in the returned list. It should be case-sensitive ("Yap" is not the same surname as "yap"). >>> names = ["Damian Henry", "Henry Ford", "Warren Elliot Henry", "Heather Fren ch Henry"] >>> surname = "Henry" >>> print (ancestors (names, surname)) [ 'Damian'] >>> names = ["Kim Kardashian West", "Kylie Jenner", "Kourtney Mary Kardashian", "Jasmine Kardashian", "Brae Kardashian", "Jasmine Kardashain"] >>> surname = "Kardashian" >>> print (ancestors (names, surname)) ['Jasmine', 'Brae']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