[EMAIL PROTECTED] wrote: > While it should be easy for me to get what I need from a list, it's > proving to be more difficult than I expected. > > I start with this list: > > [ 6.24249034e-01+0.j 5.11335982e-01+0.j 3.67333773e-01+0.j > 3.01189122e-01+0.j 2.43449050e-01+0.j 1.82948476e-01+0.j > 1.43655139e-01+0.j 9.91225725e-02+0.j]
No, that's a numpy array. > and I want a list of floats of only the first 6 digits for each value. If I > write: > for i in listname: > print i > > I get this: > > (0.624249034424+0j) > (0.511335982206+0j) > (0.367333773283+0j) > (0.301189121704+0j) > (0.243449050439+0j) > (0.182948475822+0j) > (0.14365513894+0j) > (0.0991225725344+0j) Those aren't tuples, but complex numbers. > I know it's embarrassingly simple, but the correct syntax eludes my > inexperienced mind. What I want is a list [0.62424, 0.51133, ...] so that I > can normalize those values. > > What is the correct syntax, please? # Extract the real components (since the imaginary components are all 0): eigvals = eigvals.real # Normalize the eigenvalues: eigvals /= eigvals.sum() -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list