title: Basics of recursion in Python
body: <blockquote>
  <p>&quot;Write a recursive function, &quot;listSum&quot; that takes a list of integers and returns the sum of all integers in the list&quot;.</p>
  </blockquote>
  <p>Example:</p>
  <pre><code>&gt;&gt;&gt; listSum([1, 3, 4, 5, 6])
  19
  </code></pre>
  <p>I know how to do this another way but not in the recursive way.</p>
  <pre><code>def listSum(ls):
      i = 0
      s = 0
      while i &lt; len(ls):
          s = s + ls[i]
          i = i + 1
      print(s)
  </code></pre>
  <p>I need the basic way to do this since special built-in functions is not allowed.</p>