meals.pop(key) will do it.
Example:
>>> meals = {}
>>> meals['breakfast'] = 'slimfast'
>>> meals['lunch'] = 'slimfast'
>>> meals['dinner'] = 'something sensible'
>>> meals
{'lunch': 'slimfast', 'breakfast': 'slimfast', 'dinner': 'something sensible'}
>>> meals.pop("breakfast")
'slimfast'
>>> meals
{'lunch': 'slimfast', 'dinner': 'something sensible'}

On 8/2/05, Greg Lindstrom <[EMAIL PROTECTED] > wrote:
Hello-
This must be simple, but for the life of me I can't figure out how to
delete an entry from a dictionary.  For example,

meals = {}
meals['breakfast'] = 'slimfast'
meals['lunch'] = 'slimfast'
meals['dinner'] = 'something sensible'

How do I eliminate 'lunch' from the dictionary so that I only have
'breakfast' and 'dinner'?

Thanks!
--greg

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to