“tree” structured list:
[(1,1,(1,1,(1,"1"))),(1,1,1),(1,),1,(1,(1,("1")))] # may be more complex
-
How to traversing it and print each item – I means the 1 and the “1”?
-
How to generate type list with same structure?
[(‘int’,’int’,(‘int’,’int’,(‘int’,’str’))),(‘int’,’int’,’int’),(‘int’,),’int’,(‘int’,(‘int’,(‘str’)))]
the ‘int’, ‘str’ here should be output of type(1) and type(“s”) as it can not been displayed on the question
Thanks!
You can create a generator that will traverse the tree for you for (1).
Here is one possible approach to (2).