Skip to content
Advertisement

How can I convert a list of strings to an array of float numbers?

I’m trying to convert a list of strings to an array of callable float numbers in Python, but I encounter an error. Here is a part of my code:

JavaScript

Advertisement

Answer

You can use a nested list comprehension for this. The first can iterate through your strings, then for each string you can str.split and convert each element to float from there.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement