0

I have objects like this:

values=[['MLH'], ['MLH', 'PC1_cov']]

That I'd like to turn into objects like this:

values=['MLH','MLH','PC1_cov']

I want to be able to accommodate lists of lists of lists, etc., etc., so I'm looking for a recursive function. Any suggestions?

Atticus29
  • 4,190
  • 18
  • 47
  • 84

1 Answers1

-1

You can achieve that with a simple for loop:

values=[['MLH'], ['MLH', 'PC1_cov']]
flat = []
for val in values:
    flat += val

The list flat contains the flattened version of your original list.

Bálint Aradi
  • 3,754
  • 16
  • 22