Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. def flatten_list(L):
  2. new_list = []
  3. for i in L:
  4. if isinstance(i, list):
  5. new_list += flatten_list(i)
  6. else:
  7. new_list.append(i)
  8. return new_list
  9.  
  10.  
  11. a = [[1,2,[3, 4, 5, [6,7,8]]],4]
  12.  
  13. print(flatten_list(a))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement