Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = [1, 2, 3, 4, [1, 2, 3, 4, 5, [1, 2, []]], 1, 2, [2, 3] ]
- def flatten(alist):
- result = []
- for datatype in alist:
- if type(datatype) is list:
- flatten(datatype)
- print "looping.."
- else:
- result.append(datatype)
- print result
- if __name__ == "__main__":
- flatten(x)
Add Comment
Please, Sign In to add comment