title: find min max of nested list python using recursion and no loops
body: <pre><code>def min_max(L):
  
      if len(L) == 1:
          res = [L[0], L[0]]
  
      else:
          res = min_max(L[1:])
  
          if (L[0] &lt; res[0]):
              res[0] = L[0]
  
          if (L[0] &gt; res[1]):
              res[1] = L[0]
  
      return res
  </code></pre>
  
  <p>Here is my code that works for regular lists. If there is only one element, that element is both the min and the max. Otherwise, we find the min and max for the elements in the list ahead of it, and then we compare, and swap if bigger or smaller.</p>
  
  <p>I should do this for nested lists. What I tried doing was adding this line of code before the <code>if len(L) == 1</code> case. </p>
  
  <pre><code>if isinstance(L[0],list):
      res = min_max(L[0])
  
  elif len(L) == 1:
      res = [L[0], L[0]]
  </code></pre>
  
  <p>This works partially, but in examples like <code>min_max([[3,2],4])</code>, returns <code>[2,3]</code> without considering the 4. How can I fix this?</p>