469,927 Members | 1,832 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

How to add pairs to a dict?

I want to keep adding pairs my phone_book dict like
so:

phone_book={'jack':2313, 'john':3436}

And then each time when a new pair is created, for
example, 'tom':5678, I want to add it to the dict so
that the dict becomes

phone_book={'jack':2313, 'john':3436}

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

Jul 18 '05 #1
1 1328
Anthony Liu schrieb:
I want to keep adding pairs my phone_book dict like
so:

phone_book={'jack':2313, 'john':3436}

And then each time when a new pair is created, for
example, 'tom':5678, I want to add it to the dict so
that the dict becomes

phone_book={'jack':2313, 'john':3436}


I assume you want

phone_book['tom'] = 5678

which leaves phone_book as

{'jack':2313, 'john':3436, 'tom':5678}

Mit freundlichen Gruessen,

Peter Maas

--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail pe********@mplusr.de
-------------------------------------------------------------------
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Robin Cull | last post: by
31 posts views Thread by Raymond Hettinger | last post: by
reply views Thread by Anthony Liu | last post: by
5 posts views Thread by rbt | last post: by
8 posts views Thread by Florian Lindner | last post: by
15 posts views Thread by George Sakkis | last post: by
15 posts views Thread by mcjason | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.