Re: A more general solution

2010-05-09 Thread Tim Chase
On 05/08/2010 10:33 PM, 3Jane wrote: You could interpret [[1,2,3,4],[5,6,7,8]] as a tree and your task as traversal of its leaves. All solutions before would not work with trees with bigger height. Here is how to traverse such trees recursively: def eventualPrint(x): for v in x: i

A more general solution

2010-05-08 Thread 3Jane
You could interpret [[1,2,3,4],[5,6,7,8]] as a tree and your task as traversal of its leaves. All solutions before would not work with trees with bigger height. Here is how to traverse such trees recursively: def eventualPrint(x): for v in x: if isinstance(v, list): eventualPrint(x)