newbie dictionary question

James Chapman
Sun Apr 21 20:43:56 EDT 2002


Hi,

I'd preferably like to use something like this but my problem is precisely
this. I have for example to dictionaries as follows:

a= {4.95:100,4.97:90,4.99:95}
b={4.95:100,4.96:99}

and I would wonder if there is an elegent way to do something like:

c = a+b
c={4.95:200,4.96:99,4.97:90,4.99:95}

thanks,

"Wolfgang Grafen" <wolfgang.grafen at gmx.de> wrote in message
news:3CC34519.E6C1063A at gmx.de...
> "James Chapman <" schrieb:

> >>> d1={'a':1,'b':2}
> >>> d2={'c':3,'b':4}
> >>> d1.update(d2)
> >>> d1
> {'b': 4, 'c': 3, 'a': 1}
>
> Hope this is what you mean but consider that the value of 'b' in d1 will
be
> overridden by the value of 'b' in d2.
>
> wolfgang
>





More information about the Python-list mailing list