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 trialRyan Hartigan
3,425 PointsDel 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
Treehouse Moderator 68,441 PointsThe 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!!!