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 trialteamz
44,723 PointsConfusion on For Loop in Python in Intro to Dictionaries
I have rewatched the videos on this one and am not sure why the items word is not the fill in the blank for all of the quiz.
It feels like they would be calling the items() method on the loop to get the iteration of the keys.
Not sure what I am doing wrong?
Here is the code:
student = {'name': 'Craig', 'foo': 'bar'}
for key in student. ____(): print(key)
2 Answers
Steven Parker
231,248 PointsThe "items" method returns both the keys and the values. If you only want the keys, you can use the "keys" method.
teamz
44,723 PointsOmigosh! Can't believe I missed that. Thank you SO MUCH for your speedy response, Steven!
Kurobe Kuro^T_T^
5,369 PointsKurobe Kuro^T_T^
5,369 Pointsi dont remember learing the key method