fork download
  1. f=lambda x:map(f,x)[::-1]if"">x>[]else x
  2.  
  3. test1 = [[1,2], [3,4]]
  4.  
  5. test2 = [[[ 1, 2, 3], [ 4, 5, 6], [ 7, 8, 9]],
  6. [[10,11,12], [13,14,15], [16,17,18]],
  7. [[19,20,21], [22,23,24], [25,26,27]],
  8. [[28,29,30], [31,32,33], [34,35,36]],
  9. [[37,38,39], [40,41,42], [43,44,45]],
  10. [[46,47,48], [49,50,51], [52,53,54]]]
  11.  
  12. test3 = [[[1,2]],
  13. [[3,4], [5]],
  14. [[6,7,8], [9], [10,11]],
  15. [[[12,13], [14,15]], [16], [17,18,19,20]],
  16. [21]]
  17.  
  18. test4 = [["Foo",["Bar",1]],
  19. 2,
  20. ["Baz"],
  21. [[["Qux"],3],3.14]]
  22.  
  23. tests = [test1, test2, test3, test4]
  24.  
  25. for test in tests:
  26. print(f(test))
Success #stdin #stdout 0.01s 8968KB
stdin
Standard input is empty
stdout
[[4, 3], [2, 1]]
[[[54, 53, 52], [51, 50, 49], [48, 47, 46]], [[45, 44, 43], [42, 41, 40], [39, 38, 37]], [[36, 35, 34], [33, 32, 31], [30, 29, 28]], [[27, 26, 25], [24, 23, 22], [21, 20, 19]], [[18, 17, 16], [15, 14, 13], [12, 11, 10]], [[9, 8, 7], [6, 5, 4], [3, 2, 1]]]
[[21], [[20, 19, 18, 17], [16], [[15, 14], [13, 12]]], [[11, 10], [9], [8, 7, 6]], [[5], [4, 3]], [[2, 1]]]
[[3.14, [3, ['Qux']]], ['Baz'], 2, [[1, 'Bar'], 'Foo']]