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 (2016, retired 2019) Dictionaries Introduction To Dictionaries

whats wrong with my code???

I copy kenneth code but result is different can anybody help me.

>>> course = {"title":"python collection","teacher":{"first_name":"kenneth",                     
"last_name":"love"}                                                                              
...                                                                                              
...                                                                                              
...                                                                                              
... }

>>> course                                                                                       
{'title': 'python collection', 'teacher': {'first_name': 'kenneth', 'last_na                     
me': 'love'}}                                                                                   
>>>   

kenneth write this

>>> course = {"title":"python collection","teacher":{"first_name":"kenneth",                     
"last_name":"love"} 

>>>course
{'teacher' : {'last_name' : 'love', 'first_name', : 'kenneth'},'title' : 'python collection' , 'video' : 22}

but in my case result was differnet. this cannot be work in python.

3 Answers

Adam Stefański
Adam Stefański
14,255 Points

That video thing You must have already added to the dictionary before.

But if the problem is that it is not in the same order, then dont worry about it. Dictionaries do not have any paticular order in their keys. They kind of just float there freely. Kenneth is going to repeat that several times during dictionary part of that course.

By the way good luck!!! I'm in a similar place in that course. Wait till You get to that second to last challenge.

Hi Craigs, I've copied your two dictionaries into my Python and this is what I've found:

d1 = {'title': 'python collection', 'teacher': {'first_name': 'kenneth', 'last_name': 'love'}}      
d2 = {'teacher' : {'last_name' : 'love', 'first_name', : 'kenneth'},'title' : 'python collection' , 'video' : 22}

The second one has a typo, as you've entered it up above. Correcting for that typo, I then run these commands:

len(d1)   # length is 2
len(d2)  # length is 3

So those are some differences, in case that helps.

Where are your '' or "" on 22?