Converting an array of string to array of float

Blockheads Oi Oi breamoreboy at yahoo.co.uk
Fri Mar 25 11:42:22 EDT 2011


On 25/03/2011 15:27, Jason Swails wrote:
> I'm guessing you have something like
>
> list1=['1.0', '2.3', '4.4', '5.5', ...], right?
>
> You can do this:
>
> for i in range(len(list1)):
>    list1[i] = float(list1[i])
>

or

for i, x in enumerate(list1):
     list1[i] = float(x)





More information about the Python-list mailing list