title: Python - Find the sum of a Nested list
body: <p>I'm having trouble of this recursive nested lists. The problem I have right now is the code work fine if the list isn't at the end of the list... I can't figure out what should I do to fix this.</p>
  
  <pre><code>def rsum(l):
      # Sum of all num in the list
      print l
      if isinstance(l[0], list):
  
          if len(l[0]) == 0:
              result = 0 + rsum(l[1:])
  
          else:
              sum_in_list = rsum(l[0])
              result = sum_in_list + rsum(l[1:])
  
      elif len(l) == 1:
          result = l[0]
  
      else:
          result = l[0] + rsum(l[1:])
  
      return result
  </code></pre>
  
  <p>So it work fine like this</p>
  
  <pre><code>l = [1, 2, [], 3, [2, 100], 4, [5], [], 2]
  print rsum(l)
  119
  </code></pre>
  
  <p>But if i do this</p>
  
  <pre><code>l = [1, 2, [], 3, [2, 100], 4, [5], [], [2]]
  IndexError: list index out of range
  </code></pre>
  
  <p>Any help or suggestion to point me in the right direction would be great</p>