From dc696ef25acd767a61de90341bb2f5df9883f3ca Mon Sep 17 00:00:00 2001 From: Cory Dean Chung Date: Mon, 14 Aug 2023 14:10:04 -0400 Subject: [PATCH] Checkpoint 1 commit 2: Wrote get_email. I got stuck with this in a couple places. The first was just getting used to the syntax. The second was that I wasn't sure of the difference between is and ==. Similar to before, I just tested the specific function in friend_functions.py using the test cases given and checked what output I was actually getting to figure out what it was doing, which wasn't always obvious when running test_friend_functions.py --- friend_functions.py | 13 +++++-------- friend_functions.pyc | Bin 3350 -> 3473 bytes 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/friend_functions.py b/friend_functions.py index f5757aa..d64b0d6 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -9,6 +9,8 @@ # Your job is to complete these functions. Remove the NotImplementedError from # each and instead write code which returns the expected values. +from people import friends, family + def count_people(people): """Counts the number of people. @@ -23,14 +25,9 @@ def count_people(people): return counted 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 - """ - raise NotImplementedError() + for person in people: + if person["name"] == name: + return person["email"] def count_favorite_colors(people, name): """Returns the number of colors liked by the named person. If there is no such person, returns None. diff --git a/friend_functions.pyc b/friend_functions.pyc index 8507c16df629f53b98ba51acb52bb9ac46c72f82..8704c09235c30b81b788e95c7add7f607fb8622c 100644 GIT binary patch delta 503 zcmYjNy-EW?5T4olzvN;9D#Spn)Kjn!E3pZvZIlft1X9Fogu`4w?~nu{Hj1tB!1s_? z`5achgDBVvI0*dv-AJ7G_Kqj-+})azpD<+M9^EKn;a1+ItV?07@>&}3up>J zCEymIX@D{`F+rJ{SfDITY*4l)4k$+x7nBQ)(4(Z$FG@w>1Rg&7w+i}zz zKDQz~E|8kI1mM~jU;#TEV$ALyy~!rQU=>CH`>iTm3m6IRw>&~P7jWrlT|l{U;lK$s z+X&6<2R}AalLGtgxSLu;x^X+|)k9(sa(c;iBzGgt>??Pg4UJ%~LTbV`a04vjWNfTp z_9?3N)LHwjTV-6!?v3rqm9-;sJgXj4itN?7!>vip6Fch+f{GiDCqVNJQ@A=-m=l=m~V^Q1y delta 340 zcmbOzJxwZ>`7`8H`{CBSQ)kn8C!5!VG3G zGo-M987vGbtY8K!Lkb&1um(F&`^G7mi~>9$!#IEh0|y%;FC*XN=geA@!PF~AuJXw(Ck6;i;PJ;4K|P*Gl&4QKt2iL1QA>yf*VL^Ky()H3i5%(IC(j_fKY^!3jo*zGr9l(