Implemented function to count people

Honestly I don't like this lesson on dictionaries! This is a perfect use
case for object-oriented programming; dictionaries are just lookup
tables. I think it makes more sense to teach dicts in the context of
price lookups, or passwords, or something that has more structure
than just a place to put names variables.
This commit is contained in:
tgaeta
2025-10-08 12:54:48 -04:00
parent 96b2529a16
commit ed1430803b
2 changed files with 2 additions and 2 deletions

View File

@@ -9,7 +9,7 @@
# Your job is to complete these functions. Remove the NotImplementedError from
# each and instead write code which returns the expected values.
def count_people(people):
def count_people(people: dict):
"""Counts the number of people.
>>> count_people(family)
@@ -17,7 +17,7 @@ def count_people(people):
>>> count_people(friends)
10
"""
raise NotImplementedError()
return len(people)
def get_email(people, name):
"""Returns the named person's email address. If there is no such person, returns None.