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

'key', 'value', and 'item' are not defined, I get an error: AttributeError: 'dict' object has no attribute 'key'

My code is this:

for key in course_minutes.key():

Full error is this:

Traceback (most recent call last): File "<stdin>", line 1, in <module>

AttributeError: 'dict' object has no attribute 'key'

I made sure to test in the Workspace but with the same result. Does Python need some sort of library (or something) for this? If not, how do I make it work?

2 Answers

Try course_minutes.keys() instead of course_minutes.key()

Well... bother! It was that simple, thank you very much Stuart!

I knew enough to assume it was something simple but obviously needed to check the syntax closer. This is a good lesson.

Thank you!