Accessing Dictionary values from within the Dictionary

Kuros kuros at pgtv.net
Fri Nov 15 00:57:33 EST 2002


Hi again,

I have created a dictionary, like so:

dict = {var1 : 0, var 2: 0}

Now, i want the third key/value pair to equal the total values of var1 and 
var2. I tried to do it this way:

dict = {var1 : 1, var 2 : 2, var3 : dict[var1] + dict[var2]}

But I get an invalid syntax error.

Could someone help me out with this?

Thanks,
Kuros



More information about the Python-list mailing list