<br><br><div class="gmail_quote">On Tue, Jun 16, 2009 at 8:59 PM, ayyaz <span dir="ltr">&lt;<a href="mailto:ayyaz84@gmail.com">ayyaz84@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

The following works also.<br>
<br>
msg = raw_input(&quot;\nPlease enter a message to print backwards: &quot;)<br>
x = range(0,len(msg))<br>
x.reverse()<br>
for i in x: print msg[i],<font color="#888888"></font></blockquote><div><br>or even simpler, allow range to generate the reverse:<br><br>range(len(msg)-1, -1, -1) <br><br>Some explanation: len will actually give you a value that is out of range, so you need len-1. So you&#39;ll start at the end, and go until you hit -1, and your step is -1. If you did -2 at the end, you&#39;ll get every other letter in reverse.<br>

<br>And simpler still, just add that (or substitute xrange) to the loop:<br><br>for i in xrange(len(msg)-1, -1,-1): print msg[i]<br><br>HTH,<br>Wayne<br></div></div><br>