Advertisement
here2share

# ultraflatten.py

Sep 11th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. # ultraflatten.py
  2.  
  3. grid=[0, [1, 2], [3, 4, (5, 6,),(7, {8, 9})], 'abc']
  4. def onedee(array):
  5.     result=[]
  6.     def scan(array):
  7.         for i in array:
  8.             if isinstance(i, (int, str)):
  9.                 result.append(i)
  10.             else: scan(i)
  11.     scan(array)
  12.     return result
  13. print onedee(grid)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement