How to add pairs to a dict?
Peter Maas
fpetermaas at netscape.net
Fri Mar 12 05:36:44 EST 2004
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 peter.maas at mplusr.de
-------------------------------------------------------------------
More information about the Python-list
mailing list