Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def flatten_list(L):
- new_list = []
- for i in L:
- if isinstance(i, list):
- new_list += flatten_list(i)
- else:
- new_list.append(i)
- return new_list
- a = [[1,2,[3, 4, 5, [6,7,8]]],4]
- print(flatten_list(a))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement