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 trialds1
7,627 PointsNested Dictionary
I'm wondering how Kenneth was able to create a nested dictionary with only one closing curly brackets in this video (4:00 min in). Amazingly, looks like he did d = {'key1': 'value1', 'key2': {'anotherkey': 'anothervalue'} without the final '}' !!!!
5 Answers
Stuart Wright
41,120 PointsGood spot - that does indeed look like an error.
In fact, if you keep watching the video, you'll see that when he explores the course dictionary, it seems that the statement with the error in it did not in fact create the dictionary. He typed:
course = {"title": "Python Collections", "teacher": {"first_name": "Kenneth", "last_name": "Love"}
This should throw a SyntaxError - I'm not sure why it didn't for Kenneth in Workspaces.
He then types 'course' into the console to explore the dictionary, and we see that the dictionary contains a 'video' key, which is not present in the statement above.
So in conclusion, I really have no idea what's going on here! :)
Kenneth Love
Treehouse Guest TeacherOur terminal in Workspaces isn't actually a terminal, it's a JavaScript version of a terminal (it's a legit shell session, just reproduced in JS) so sometimes it's weird with overwriting. You noticed how I jumped back in the line before I started typing? So that adds characters to the line, but the emulator has problems displaying this.
Gabbie Metheny
33,778 PointsWhen this overwriting happens, I can usually remedy it by resizing the console (dragging it all the way down, then back up) in Workspaces-- Kenneth occasionally uses this trick to effectively clear the console. If I'm getting overwriting, and just want to verify what I'm actually typing, I'll drag the console down and back up before hitting "enter." Hope that helps!
ds1
7,627 PointsThanks, Stuart... glad I'm not missing something. Maybe they edited the video.
ds1
7,627 PointsOh, ok- thanks Kenneth. I'm enjoying these classes & learning alot!
ds1
7,627 PointsThanks, Gabbie Metheny !