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 trialDavid Bell
16,997 PointsWhy is the output of my_dict.values() different in the video, compared to the challenge or workspace compiler?
While completing the dictionary challenge, i was hung up a little by the output of .values(). In the video, the output appears to be just the values of the dictionary, with no format. With the workspace compiler, the output is captured in "dict_values()" Maybe this is something that only happens with list values?
This threw me off for a while, until I realized that I needed to add the values from my for loop, rather append (which worked fine for a previous step in the challenge, though not values() related)
It seems like this would be good to touch on, though I've definitely learned a few things the hard way about debugging method output.
1 Answer
beven nyamande
9,575 Pointsyou can access the elements of a dictionary using the following methods
my_dictionary.items() # yu should be able to iterate between the key and values
my_dictionary.keys() # only iterate over dictionary keys
my_dictionary.values() # only over the values