In Python, how do I convert all of the items in a list to floats? -


i have script reads text file, pulls decimal numbers out of strings , places them list.

so have list: ['0.49', '0.54', '0.54', '0.54', '0.54', '0.54', '0.55', '0.54', '0.54', '0.54', '0.55', '0.55', '0.55', '0.54', '0.55', '0.55', '0.54', '0.55', '0.55', '0.54']

how convert each of values in list string float?

i have tried:

for item in list:     float(item) 

but doesn't seem work me.

[float(i) in lst] 

to precise, creates new list float values. unlike map approach work in py3k.


Comments