Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Collections (Retired) Dictionaries Membership

Holden Glass
Holden Glass
6,077 Points

Don't understand what to do.

I know what the program wants me to do but I don't understand how to do it.

counts.py
# You can check for dictionary membership using the
# "key in dict" syntax from lists.

### Example
# my_dict = {'apples': 1, 'bananas': 2, 'coconuts': 3}
# my_list = ['apples', 'coconuts', 'grapes', 'strawberries']
# members(my_dict, my_list) => 2

def members(d, k):

2 Answers

Chris Howell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,702 Points

Hi Holden Glass

Just be aware that this challenge is part of the Retired Python Collections. And that there is a New Python Collections

For the challenge you are working on here. Kenneth gave you a HINT that you will be using the in keyword to check a list/dict for membership ( aka check if an item is IN another list).

Basically, you will write a function with 2 parameters. First parameter will end up holding a dictionary (key/value pairs), and the second parameter will hold a List of just keys. You will have to find a way to hint hint iterate through your list of keys and see if they are IN your Dict list of keys. Making sure you are keeping a running count of them, and make sure you return that count.

Let me know if that helps?

Holden Glass
Holden Glass
6,077 Points

Yes thank you. I have a much better Idea on what to do now.

Omid Ashtari
Omid Ashtari
4,813 Points

hey Holden Glass, how come the new 'collections' is not placed in the Python track instead of the retired version? any advantages to doing the old version vs. the new one? or just skip to the new collections track?

Omid Ashtari
Omid Ashtari
4,813 Points

ugh, sorry, I meant to ask Chris Howell

Chris Howell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,702 Points

I think its because they scheduled retiring of Python Collections v1 for Jan 31st 2017.

I would assume that Python Collections v2 will replace it on that date.

This probably gives the instructor time to work out any kinks in the challenge/quizzes before it becomes the final replacement in the Track.

Though these are only assumptions, they may have a better reason for not immediately replacing it. :)

Holden Glass
Holden Glass
6,077 Points

it means I have 29 days to complete the track!