Alistair King wrote: > the code works great now. I know these things are quite simple to learn > from books etc.. but i would be lost without this mailinglist, from lack > of time. Hopefully soon i can give something more complicated. > I ended up doing the dictionary formatting properly and the new code is:
> heavy = raw_input("\n\n@@@@@@@@@@@@@@@@@@\n\nPlease enter the heaviest > atom for which you obtained percentage values for, but not Oxygen or > Hydrogen, ie, 'C', 'N', 'S', 'Br'...: ") > > def updateDS1v(Fxas, x): > if Fxas !=0 and DS1v.get(x)!=None: > value = DSvalues.get(heavy) > floatvalue = float(value) > atoms = DS1v.get(x) + Fxas*floatvalue > else: > value = DSvalues.get(heavy) > floatvalue = float(value) > DS1v[x] = Fxas*floatvalue > > updateDS1v(FCas, 'C') > updateDS1v(FHas, 'H') > updateDS1v(FOas, 'O') > updateDS1v(FNas, 'N') > updateDS1v(FSas, 'S') > updateDS1v(FClas, 'Cl') > updateDS1v(FBras, 'Br') > updateDS1v(FZnas, 'Zn') > it works perfectly now Probably not. Have you manually verified the result with more than one example? Where does 'heavy' come from? Is that black hole 'atoms' intentional? # I'm just guessing here for k, v in DSvalues.iteritems(): DSvalues[k] = float(v) def updateDS1v(Fxas, x): DS1v[x] = DS1v.get(x, 0) + Fxas*DSvalues[x] Peter -- http://mail.python.org/mailman/listinfo/python-list