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 Key Management

Hai Phan
Hai Phan
2,442 Points

Why the output is reversed?

At 1:03 the output is reversed, why that happens?

1 Answer

It’s not reversed, it just appears to be. Or in other words, it was not reversed on purpose/predictable way. Maps don’t keep items in sorted order. If you print the map once again there is no guarantee that the order will be the same as the last time. Try it for yourself, make a map and print it a few times in a row.

Hai Phan
Hai Phan
2,442 Points

Now I see, but when I try by myself it still comes out the same way I input. Anyway, for now, I know Dict doesn't have order and they can come with whatever order.