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 Introducing Dictionaries Introducing Dictionaries Update and Mutate Dictionaries

Ryan Hartigan
Ryan Hartigan
3,425 Points

Del takes the "value" as an argument or the "key"?

In this video you mention that del takes one argument, the value that you want to delete. But then I think you passed in the key into del. If del takes the value as an argument, the wouldn't that mean you cannot have multiple keys with the same value because del would delete all the keys associated with that value?

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

The world โ€œvalueโ€ was unfortunately being used in two different contexts. Thereโ€™s the value associated with a dict key, then thereโ€™s the value (aka thing or object) that you are trying to delete.

When removing a key / value pair from a dictionary, you remove the key and the value is removed automatically. So it is the key that is given to the del command.

Every key in a dictionary must have a value, even if that value is None.

Post back if you need more help. Good luck!!!