473,382 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

dictionary question

i have a dictionary. inside this dictionary i have several list and inside
each list i have data.

How can i do for add data to these list.

this is my code:

conex = {'tipoconex': ['1', '0'], 'conexionS': ['cliente1', 'cliente2'],
'clave': ['pepo', 'joan'], 'usuario': ['pepe', 'juan']}

thank you
Regards
Jose
Jul 18 '05 #1
2 1252
On Wed, Feb 04, 2004 at 10:47:49PM +0100, Jos� Carlos wrote:
i have a dictionary. inside this dictionary i have several list and inside
each list i have data.

How can i do for add data to these list.


You can change the dictionary by using methods that mutate its values:
conex = {'tipoconex': ['1', '0'], 'conexionS': ['cliente1', 'cliente2'], .... 'clave': ['pepo', 'joan'], 'usuario': ['pepe', 'juan']} conex['tipoconex'].append(3)
conex['tipoconex'] ['1', '0', 3] conex['tipoconex'][0] = 'None' ['None', '0', 3]

You can also change the keys by item assignment: conex['tipoconex'] = None
conex
conex

{'clave': ['pepo', 'joan'], 'conexionS': ['cliente1', 'cliente2'],
'tipoconex': None, 'usuario': ['pepe', 'juan']}

If this doesn't help, you should tell us more about what you want to do.

Jeff

Jul 18 '05 #2
On 4 Feb 2004, José Carlos <- jo********@siadv.com wrote:
i have a dictionary. inside this dictionary i have several list and inside
each list i have data. How can i do for add data to these list. conex = {'tipoconex': ['1', '0'], 'conexionS': ['cliente1', 'cliente2'],
'clave': ['pepo', 'joan'], 'usuario': ['pepe', 'juan']}


If you write conex[Key] the object returned is the corresponding value;
if the value is a list you can use all list methods with that object.

E.g:
conex = {'tipoconex': ['1', '0'], 'conexionS': ['cliente1', 'cliente2'], .... 'clave': ['pepo', 'joan'], 'usuario': ['pepe', 'juan']} conex['clave'].append('juan')
conex {'clave': ['pepo', 'joan', 'juan'], 'conexionS': ['cliente1',
'cliente2'], 'tipoconex': ['1', '0'], 'usuario': ['pepe', 'juan']}

KP

--
'Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe. "Lewis Carroll" "Jabberwocky"
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Mudd | last post by:
I must be missing something here. It's clearly faster to lookup an item directly in a dictionary than to scan through a list. So when I have a large lookup table I always load it in the form of a...
8
by: Rodd Snook | last post by:
I have an application which makes extensive use of the Scripting.Dictionary object. I'm not doing anything silly like putting them outside the page scope -- just creating quite a few of them and...
26
by: Alan Silver | last post by:
Hello, I have a server running Windows Server 2003, on which two of the web sites use the MegaBBS ASP forum software. Both sites suddenly developed the same error, which seems to be connected to...
90
by: Christoph Zwerschke | last post by:
Ok, the answer is easy: For historical reasons - built-in sets exist only since Python 2.4. Anyway, I was thinking about whether it would be possible and desirable to change the old behavior in...
3
by: Mark Rae | last post by:
Hi, Is it possible to use a Dictionary<int, stringor even Dictionary<string, stringas the DataSource for a DropDownList directly, i.e. without having to iterate through the the Dictionary's...
8
by: akameswaran | last post by:
I wrote up a quick little set of tests, I was acutally comparing ways of doing "case" behavior just to get some performance information. Now two of my test cases had almost identical results which...
20
by: Gustaf | last post by:
This is two questions in one really. First, I wonder how to convert the values in a Dictionary to an array. Here's the dictionary: private Dictionary<Uri, Schemaschemas = new Dictionary<Uri,...
18
by: Marko.Cain.23 | last post by:
Hi, I create a dictionary like this myDict = {} and I add entry like this: myDict = 1 but how can I empty the whole dictionary? Thank you.
11
by: Dan Upton | last post by:
This might be more information than necessary, but it's the best way I can think of to describe the question without being too vague. The task: I have a list of processes (well, strings to...
0
by: Gary Herron | last post by:
Dan Upton wrote: Yes. Create a list of keys, and loop through it: pids = procs_dict.keys() for pid in pids: if procs_dict.poll() != None # do the counter updates del procs_dict Then the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.