Ben Finney wrote: > Alistair King <[EMAIL PROTECTED]> writes: > > >> Ben Finney wrote: >> >>> Even better, work on a minimal program to do nothing but reproduce >>> the unexpected behaviour. If you get to such a program and still >>> don't understand, then post it here so others can run it >>> themselves and explain. >>> >> ive checked the values and XDS is actually returning a string where i >> want a float ie '123.45' not 123.45. >> > > Can you please post a small, complete program that shows the behaviour > you want explained? > > You get this program by writing it -- either by cutting away > irrelevant parts of the existing program, or (better) writing a new > program from scratch that does nothing except demonstrate the > behaviour. > > Note that in the process of getting such a program behaving this way, > you may end up understanding the problem better. > > i have seemed to work out most of the problems from the previous code, now i have: ...................................................................................................................................................
heavy = raw_input("\n\n@@@@@@@@@@@@@@@@@@\n\nPlease enter the heaviest atom for which you obtained percentage values for, but not Oxygen, eg, 'C', 'N', 'S', 'Br'...: ") print DSvalues def updateDS1v(Fxas, x): if Fxas != 0: value = DSvalues.get(heavy) floatvalue = float(value) atoms = DS1v.get(x) + Fxas*floatvalue DS1v[x] = atoms updateDS1v(FCas, 'C') print DS1v ................................................................................................................................................... the problem now is converting badly formatted dictionary values into floats ive been trying something like this, where 'value' is a typical entry into the dictionary: ................................................................................................................................................... IDLE 1.1 >>> value = "'0.064250000000001084'" >>> print float(value) and get the error, in IDLE and the code as: Traceback (most recent call last): File "<pyshell#3>", line 1, in -toplevel- print float(value) ValueError: invalid literal for float(): '0.064250000000001084' ................................................................................................................................................... Is there any other way of removing double and single quotes from a number, as a string, to give the float value again? I know it would be easier to create a properly formatted dictionary again and i will do that but it would be good to know as i want to get this program running properly to get some results i need for work. Everything else seems to be working fine but this. thanks a -- Dr. Alistair King Research Chemist, Laboratory of Organic Chemistry, Department of Chemistry, Faculty of Science P.O. Box 55 (A.I. Virtasen aukio 1) FIN-00014 University of Helsinki Tel. +358 9 191 50392, Mobile +358 (0)50 5279446 Fax +358 9 191 50366 -- http://mail.python.org/mailman/listinfo/python-list