title: convert recursion into iteration python
body: <pre><code>def nested_depth(L):
  """
  
  &gt;&gt;&gt; nested_depth([1, 2, 3])
  1
  &gt;&gt;&gt; nested_depth([1, [2, 3], 4])
  2
  """
  
      return (1 + max([nested_depth(x) for x in L])
              if isinstance(L, list) else 0)
  </code></pre>
  
  <p>How to convert this recursive code into iterative code? i.e. we have to use loop and we are not allowed to call the function itself.</p>
  
  <p>Thanks</p>