Possible Duplicate:
Flatten (an irregular) list of lists in Python
Is there a way to store the results without having to write every sublist name? the numbers in every array are just examples of what I want to do. Thank you in advance.
_store = []
_arr4 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
_arr3 = [1, 2, 3, _arr4, 5, 6, 7, 8, 9]
_arr2 = [1, 2, 3, 4, 5, 6, _arr3, 8, 9]
_arr = [1, 2, 3, _arr2, 5, 6, 7, 8, 9]
for _value in _arr:
#If value is a list get it, go over that list and so on
if isinstance( _value, list ):
_store.append(_value)
_sub_list = _value
if isinstance( _sub_list, list ):
_store.append( _sub_list)
_sub_sub_list = _sub_list
if isinstance( _sub_sub_list, list ):
_store.append( _sub_list)
_sub_sub_sub_list = _sub_list
#and so on...
print _store