Advertisement
cymplecy

flatten list

Mar 30th, 2015
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.19 KB | None | 0 0
  1. def flatten(source):
  2.     result = []
  3.     for e in source:
  4.         if isinstance(e,list):
  5.             result.extend(flatten(e))
  6.         else:
  7.             result.append(e)
  8.  
  9.     return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement