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
Albert Lee
Courses Plus Student 1,372 Pointstest_dict = {"a": 1, "b": 2, "a": 3} why when I type test_dict["a"], the outcome will be the last order ?
as title
why is when I run test_dict["a"] it become 3 but not 1 ? what's the rule?
" It'll be 3 because the keys are created in order. First it's 1 and then the 3 is assigned later."
the value will always show the last one I assign?
1 Answer
Steven Parker
243,656 PointsA dictionary can only store one value for each key. If you assign the same key more than once it will replace what it had before.