I have a nested list of lists occurring in the form of
A = [[a,b],[c,d]] or [[[a,b],[c,d]]] or [[[[a,b],[c,d]]]] or [[[[[a,b],[c,d]]]]]
and so on. These forms of A
don't occur at the same time.
How can I code to peel the list, no matter how nested A may be, and obtain only:
[a,b]
[c,d]
I tried this:
def Peel_list(Features):
try:
for lon,lat in Features:
print((lon,lat))
except:
for Feature in Features:
for t_list in Feature:
for A in t_list:
for lon,lat in A:
print((lon,lat))
return()
But it only works for limited A.