removing dictionary key-pair

akameswaran at gmail.com akameswaran at gmail.com
Fri Jun 9 16:25:10 CEST 2006


JD wrote:
> Hello,
>
> I try to remove a dictionary key-pair (remove an entry),
> but I'm unsuccessful. Does anyone know how to achieve this?
>
> Thanks

Assuming you know the key:

d = {"foo":1,"bar":2}
print d
del(d["foo"])
print d




More information about the Python-list mailing list