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
d = dict(a=1, b=2, c=3)
print d
del d['a']
print d
--
http://mail.python.org/mailman/listinfo/python-list
bruno at modulix wrote:
> 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
>
>
> mydict = {"key" : "value"}
> del mydict(key)
grmf... Typo. This is:
del mydict['key']
of course...
--
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
--
http://mail.python.org/mailman/listinfo/python-list
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
>>> d = {1: "one", 2: "two", 3: "three"}
>>> del d[2]
>>> d
{1: 'one', 3: 'three'}
>>>
regards
Steve
--
Steve Holden +44 150
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
mydict = {"key" : "value"}
del mydict(key)
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p
JD>I try to remove a dictionary key-pair (remove an entry),
>>> d = {1:2, 3:4}
>>> d
{1: 2, 3: 4}
>>> del d[1]
>>> d
{3: 4}
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
I try to remove a dictionary key-pair (remove an entry),
but I'm unsuccessful. Does anyone know how to achieve this?
Thanks
--
http://mail.python.org/mailman/listinfo/python-list