-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from Unimpressions/Issue-#2_Solution
Initial Solution for Issue #2: Profile Lookup
- Loading branch information
Showing
1 changed file
with
41 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,41 @@ | ||
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 lookup in contacts: | ||
lookupname = lookup.get('firstName') | ||
if lookupname.casefold() == name.casefold(): | ||
lookupfield = lookup.get(field) | ||
if lookupfield == lookup[field]: | ||
return lookupfield | ||
else: | ||
return "No Such property." | ||
return "No such contact." | ||
|
||
#Change these values to test your function | ||
print(look_up_profile("Akira", "number")) |