python recursion problem [duplicate]
Possible Duplicate:
Flatten (an irregular) list of lists in Python
hello I build a small program using recursion in Python, but am stuck in a place to solve the problem at least I do not know how to row, waiting for your help thank you in advance
intertwined with a list following the given problem using recursi开发者_运维知识库on I want to print on a single list.
example
this is my list
enter code here [[[13, 7], 90], 2, [1, 100], 8, 6]
expected result
enter code here[13,7,90,2,1,100,8,6]
Like this:
startlist=[[[13, 7], 90], 2, [1, 100], 8, 6]
endlist=[]
def flatten(l):
for item in l:
if type(item) in (type([]),type(())):
flatten(item)
else:
endlist.append(item)
精彩评论