created the first two functions of friend_functions

I didn't properly read the instructions and I kept getting confused by what the data looked like so I created a trials
folder and I used it to dissect the data. Once it was clear that I was looking at a list of dictionaries, it became
very easy to create my first two functions. It's necessary to know what the dataset looks like structurally.
This commit is contained in:
ilmabura
2025-10-20 16:01:43 -04:00
parent b8fc500299
commit 2899a3250a
2 changed files with 105 additions and 5 deletions

95
trials.py Normal file
View File

@@ -0,0 +1,95 @@
family = [
{
"name": "Tad Winters",
"email": "ligula.aenean@hotmail.edu",
"favorite_colors": ["aqua", "red"],
},
{
"name": "Raphael Chambers",
"email": "ac.eleifend.vitae@protonmail.com",
"favorite_colors": ["blue"],
},
{
"name": "Perry Calderon",
"email": "mus.donec@outlook.org",
"favorite_colors": ["black", "white", "grey"],
},
{
"name": "Walker Hurley",
"email": "auctor.odio@icloud.ca",
"favorite_colors": ["red", "yellow", "blue", "orange"],
},
{
"name": "Clementine Joseph",
"email": "hendrerit@aol.co.uk",
"favorite_colors": ["yellow", "aqua", "black"],
}
]
friends = [
{
"name": "Connor Rodriguez",
"email": "maecenas@yahoo.edu",
"favorite_colors": ["aqua", "teal", "sea foam", "turquoise"],
},
{
"name": "Rosalyn Hubbard",
"email": "elit.pharetra@google.edu",
"favorite_colors": ["red", "yellow", "black"],
},
{
"name": "Thomas Puckett",
"email": "sit.amet@aol.net",
"favorite_colors": ["blue"],
},
{
"name": "Yuli Reynolds",
"email": "augue.malesuada@google.edu",
"favorite_colors": [],
},
{
"name": "Joy Tate",
"email": "risus.a.ultricies@hotmail.org",
"favorite_colors": ["white", "grey", "sand"],
},
{
"name": "Prescott Price",
"email": "cursus.nunc@yahoo.edu",
"favorite_colors": ["red", "blue", "green"],
},
{
"name": "Josephine Keller",
"email": "nulla@protonmail.edu",
"favorite_colors": ["black"],
},
{
"name": "Isadora Carney",
"email": "sagittis.lobortis@protonmail.co.uk",
"favorite_colors": ["aqua", "lime"],
},
{
"name": "Jelani West",
"email": "vehicula.pellentesque.tincidunt@yahoo.org",
"favorite_colors": ["grey", "beige", "tan"],
},
{
"name": "Gay Pittman",
"email": "etiam.bibendum@yahoo.org",
"favorite_colors": ["yellow"],
}
]
def get_email(people, name):
"""Returns the named person's email address. If there is no such person, returns None.
>>> get_email(family, "Tad Winters")
"ligula.aenean@hotmail.edu"
>>> get_email(friends, "Tad Winters")
None
"""
for n in friends:
if n['name']=="Tad Winters":
print(n['email'])
else:
print(None)