Hello,
I try to remove a dictionary key-pair (remove an entry),
but I'm unsuccessful. Does anyone know how to achieve this?
Thanks 6 23239
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
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 in 'o****@xiludom.gro'.split('@')])"
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
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...
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tim N. van der Leeuw |
last post by:
Hi,
I'd like to remove keys from a dictionary, which are not found in a
specific set. So it's kind of an intersection-operation.
I can create a new dictionary, or a loop over all keys and test...
|
by: tarunbajaj |
last post by:
Hi all,
I am inserting a key in HttpContext.Cache
Some keys I am caching for multiple days. Out of these once a while I
need to reset cache entry of specific key.
I can do a lot to reset the...
|
by: john wright |
last post by:
I have a dictionary oject I created and I want to bind a listbox to it. I
am including the code for the dictionary object.
Here is the error I am getting:
"System.Exception: Complex...
|
by: Nico Grubert |
last post by:
Hi there,
I am looking for a way to sort a list containing dictionaries.
This is my example list:
I want to sort the list by dictionary's key 'from_datetime' so the
sorted list should be:
|
by: Brian L. Troutwine |
last post by:
I've got a problem that I can't seem to get my head around and hoped
somebody might help me out a bit:
I've got a dictionary, A, that is arbitarily large and may contains
ints, None and more...
|
by: Tina I |
last post by:
Hi everyone,
I have a small, probably trivial even, problem. I have the following HTML:
I need to make this into a dictionary like this:
dictionary = {"METAR:" : "ENBR 270920Z 00000KT 9999...
|
by: robinsiebler |
last post by:
I have a data structure that looks like this:
# dates = {'2007': {'25': {'06/23/07': {'aerosmith': ,
# 'Metallica': },
# 'last_song': }}}...
|
by: kdt |
last post by:
Wow, I really am full of horrid questions today.
I have a dictionary with a list of patterns:
>>> words = {'sho.':6, '.ilk':8,'.an.':78 }
Where the "." character means any pattern - this can...
|
by: GTXY20 |
last post by:
Have a little bit of a problem:
I have the following dictionaries:
d={'1': , '3': , '2': , '4': }
update={'a': 10, 'c': 4, 'b': 5, 'd': 1}
I use the following to output:
|
by: =?Utf-8?B?THVpZ2k=?= |
last post by:
Hi all,
having a dictionary of <int, string(C# 2.0) is there a way to retrieve the
key for a specific value (of type string)?
Obviously I populate the Dictionary with not duplicated strings.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |