-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4512bdc
commit c5aa321
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) |