generated from mwc/lab_weather
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user