Here is a messy nested list that I need to convert into a list of numbers:
nested_list = [
["[63]"],
["[61]"],
["[7]"],
["[63]"],
["[80, 18]"],
["[80, 43, 18, 20]"]
]
I know it's a mess, but I have to work with this data. The desired output should look like this:
[63, 61, 7, 63, 80, 18, 80, 43, 18, 20]
Is there a way to achieve this with minimal looping?
I tried using `flat()` on the nested list like this: nested_list .flat(2)
, which gave me:
[ '[63]', '[61]', '[7]', '[63]', '[80, 18]', '[80, 43, 18, 20]' ]
I also attempted a combination of reduce and concat based on this but ran into issues since the items are in string format. Any suggestions on how to proceed would be appreciated.