Simple list question

C GIllespie csgcsg39 at hotmail.com
Fri Jan 30 16:47:54 CET 2004


Dear all,

I have a list something like this: ['1','+','2'], I went to go through and
change the numbers to floats, e.g. [1,'+',2]. What's the best way of doing
this? The way I done it seems wrong, e.g.

nod=['1','+','2']
i=0
while i<len(nod):
    if nod[i] !='+' or nod[i] !='-' or nod[i]!='*' or nod[i] != '/' or
nod[i] != '(' or nod[i] != ')':
        nod[i] = float(nod[i])
    i = i + 1

Comments?

Thanks

Colin





More information about the Python-list mailing list