title: How do you create a palindrome generator as a recursive function?
body: <p>Inverting a string is easy:</p>
  <pre class="lang-py prettyprint-override"><code>def invert(text):
      if text == &quot;&quot;:
          return text
      else:
          return invert(text[1:]) + text[0]
  </code></pre>
  <p>I'm trying to create a recursive function that also keeps the original string, i.e.:
  <code>1234</code> -&gt; <code>1234 4321</code> and <code>123</code> -&gt; <code>12321</code>. What's the most efficient way to do this?</p>