fork(1) download
  1. def flat_list(array):
  2. d=[]
  3. for i in array:
  4. if not isinstance(i, list):
  5. d.append(i)
  6. else:
  7. d.extend(flat_list(i))
  8. return d
  9.  
  10. print(flat_list([1, [2, 2, 2], 4]))
Success #stdin #stdout 0.02s 9112KB
stdin
Standard input is empty
stdout
[1, 2, 2, 2, 4]