Skip to content

Commit

Permalink
Merge pull request #82 from Unimpressions/Issue-#2_Solution
Browse files Browse the repository at this point in the history
Initial Solution for Issue #2: Profile Lookup
  • Loading branch information
the-vampiire authored Oct 11, 2018
2 parents a92501a + 36826f9 commit 0a01dce
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions beginner/Profile-Lookup_Unimpressions.py
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"))

0 comments on commit 0a01dce

Please sign in to comment.