[Tutor] Re: one line code

Andrei project5 at redrival.net
Tue Apr 5 13:14:14 CEST 2005

Alan Gauld <alan.gauld <at> freenet.co.uk> writes:

> > With other words I'd like to tell Python: Convert into a float if 
> > possible, otherwise append anyway. 
> [ (type(x) == type(5) and float(x) or x) for x in mylist ]

Almost fell for it too, but the original list contains numbers 
stored as strings :).


More information about the Tutor mailing list