Reversing a string in Python using a loop?
<p>I'm stuck at an exercise where I need to reverse a random string in a function using only a loop (for loop or while?).</p>

<p>I can not use <code>".join(reversed(string))</code> or <code>string[::-1]</code> methods here so it's a bit tricky.</p>

<p>My code looks something like this:</p>

<pre><code>def reverse(text):
    while len(text) &gt; 0:
        print text[(len(text)) - 1],
        del(text[(len(text)) - 1]
</code></pre>

<p>I use the <code>,</code> to print out every single letter in text on the same line!</p>

<p>I get invalid syntax on <code>del(text[(len(text)) - 1]</code></p>

<p>Any suggestions?</p>