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 Teacher Stats

oliverchou
oliverchou
20,886 Points

Why is there a SyntaxError?

stage.py
def stats(dict_tea):
    li = []
    for key in dict_tea:
        add = [key, len[dict_tea[key]]
        li.append(add)
    return li

And here's the code that I tested the function.

test.py
test_dict = {'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'],
 'Kenneth Love': ['Python Basics', 'Python Collections']}
print (stats(test_dict))

I can't figure out why it kept giving me an SyntaxError at the "li.append()"? Any idea about that?

Cheo R
Cheo R
37,150 Points

Your error is not at

li.append()

but at

[key, len[dict_tea[key]]

Can you see the syntax error.

oliverchou
oliverchou
20,886 Points

Oh, I was dizzy! Anyway, thanks! :)