Code: Alles auswählen
def foo(lst):
if len(lst) == 1:
return lst
else:
head,tail=lst
return [head] + foo(tail)
if __name__ =='__main__':
a =['a', ['b', ['c']]]
print foo(a)
Grüßen
Code: Alles auswählen
def foo(lst):
if len(lst) == 1:
return lst
else:
head,tail=lst
return [head] + foo(tail)
if __name__ =='__main__':
a =['a', ['b', ['c']]]
print foo(a)
Code: Alles auswählen
[a,[b,[c]]]
Code: Alles auswählen
[a,b,c]