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!
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

jessicamurr
3,313 PointsCan you update the keys without changing the values?
In the video Update and Mutate Dictionaries, we update the values of the keys by passing the key:
course['teacher'] = 'Treasure'
However, what if I wanted to change the key itself instead of changing the value of that key? Like if I wanted to change 'teacher' to 'professor' while keeping the value the same?
Thanks for your help!
1 Answer

Steven Parker
225,756 PointsYou can't change a key, but you can create a new key and assign it the value of the old one, then delete the old key.
jessicamurr
3,313 Pointsjessicamurr
3,313 PointsThank you!