Skip to content

Commit

Permalink
Profile Lookup #2 Solution (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikxtaco authored and the-vampiire committed Oct 5, 2019
1 parent 4512bdc commit c5aa321
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions python/beginner/Profile-Lookup_nikxtaco.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["JavaScript", "Gaming", "Foxes"]
}
]

def look_up_profile(name, field):

for contact in contacts:
if contact["firstName"] == name and contact.get(field) != None:
return contact[field]
elif contact.get(field) == None:
return "No such property exists."
return "Such a contact doesn't exist."

#Change these values to test your function
print(look_up_profile("Akira", "likes"))

0 comments on commit c5aa321

Please sign in to comment.