Dictionaries
Gary Herron
gherron at islandtraining.com
Wed Oct 18 11:35:43 EDT 2006
More information about the Python-list mailing list
Wed Oct 18 11:35:43 EDT 2006
- Previous message (by thread): Dictionaries
- Next message (by thread): Dictionaries
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Lad wrote:
> How can I add two dictionaries into one?
> E.g.
> a={'a:1}
> b={'b':2}
>
> I need
>
> the result {'a':1,'b':2}.
>
> Is it possible?
>
> Thank you
> L.
>
>
Yes, use update. Beware that this modifies a dictionary in place rather
than returning a new dictionary.
>>> a={'a':1}
>>> b={'b':2}
>>> a.update(b)
>>> a
{'a': 1, 'b': 2}
Gary Herron
- Previous message (by thread): Dictionaries
- Next message (by thread): Dictionaries
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list