By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,089 Members | 2,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,089 IT Pros & Developers. It's quick & easy.

dictionary question

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.