3. lookup_friends_heights This function takes a friends database (a list of dictionaries, like the previous functions) and a list of friends names, and it returns a list of heights for the specified friends. If a given friend's name is not present in the friends database, we put a None in the corresponding slot. We assume that there will be at most one friend with a given name in the list. You may want to use nested for-loops for this function. Sample calls should look like this. >>> lookup_friends_heights([{"name":"todd", "height":170},{"name":"sarah", "height":165},{"name":"dweezil", "height":175}], ["dweezil", "sarah"]) [175, 165] >>> lookup_friends heights([{"name":"todd", "height" :170},{"name":"sarah", "height":165},{"name": "dweezil","height":175}], ["sarah", "eliza", "dweezil"]) [165, None, 175]
3. lookup_friends_heights This function takes a friends database (a list of dictionaries, like the previous functions) and a list of friends names, and it returns a list of heights for the specified friends. If a given friend's name is not present in the friends database, we put a None in the corresponding slot. We assume that there will be at most one friend with a given name in the list. You may want to use nested for-loops for this function. Sample calls should look like this. >>> lookup_friends_heights([{"name":"todd", "height":170},{"name":"sarah", "height":165},{"name":"dweezil", "height":175}], ["dweezil", "sarah"]) [175, 165] >>> lookup_friends heights([{"name":"todd", "height" :170},{"name":"sarah", "height":165},{"name": "dweezil","height":175}], ["sarah", "eliza", "dweezil"]) [165, None, 175]
Chapter3: Performing Calculations With Formulas And Functions
Section: Chapter Questions
Problem 3.15CP
Related questions
Question
![3. lookup_friends_heights
This function takes a friends database (a list of dictionaries, like the previous functions) and a list of friends names, and
it returns a list of heights for the specified friends. If a given friend's name is not present in the friends database, we put
a None in the corresponding slot. We assume that there will be at most one friend with a given name in the list. You
may want to use nested for-loops for this function.
Sample calls should look like this.
>>> lookup_friends_heights([{"name":"todd","height":170},{"name": "sarah", "height":165},{"name":"dweezil", "height":175}],
["dweezil", "sarah"])
[175, 165]
>>> lookup_friends_heights([{"name": "todd","height":170},{"name": "sarah","height":165},{"name": "dweezil", "height":175}],
%3D
["sarah", "elíza", "dweezil"])
[165, None, 175]](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0b28b7e8-d393-4aa8-b233-2c11ecf05f14%2F1f46cae7-9fce-49b8-a22b-11f2fb17f2e9%2Fg7pjapp_processed.jpeg&w=3840&q=75)
Transcribed Image Text:3. lookup_friends_heights
This function takes a friends database (a list of dictionaries, like the previous functions) and a list of friends names, and
it returns a list of heights for the specified friends. If a given friend's name is not present in the friends database, we put
a None in the corresponding slot. We assume that there will be at most one friend with a given name in the list. You
may want to use nested for-loops for this function.
Sample calls should look like this.
>>> lookup_friends_heights([{"name":"todd","height":170},{"name": "sarah", "height":165},{"name":"dweezil", "height":175}],
["dweezil", "sarah"])
[175, 165]
>>> lookup_friends_heights([{"name": "todd","height":170},{"name": "sarah","height":165},{"name": "dweezil", "height":175}],
%3D
["sarah", "elíza", "dweezil"])
[165, None, 175]
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage