title: Finding the dimension of a nested list in python
body: <p>We can create multi-dimensional arrays in python by using nested list, such as:</p>
  
  <pre><code>A = [[1,2,3],
       [2,1,3]]
  </code></pre>
  
  <p>etc.
  In this case, it is simple nRows= len(A) and nCols=len(A[0]). However, when I have more than three dimensions it would become complicated.</p>
  
  <pre><code>A = [[[1,1,[1,2,3,4]],2,[3,[2,[3,4]]]],
       [2,1,3]]
  </code></pre>
  
  <p>etc.
  These lists are legal in Python. And the number of dimensions is not a priori.
  In this case, how to determine the number of dimensions and the number of elements in each dimension. </p>
  
  <p>I'm looking for an algorithm and if possible implementation. I believe it has something similar to DFS. Any suggestions?</p>
  
  <p>P.S.: I'm not looking for any existing packages, though I would like to know about them. </p>