title: Python: String index out of range
body: <p>I have had a look at a lot of previous questions put up, but still couldn't find anything that'll help me here.
  Here's a code I wrote to Reverse a sentence.
  I could have used split() function, but I tried to do without it anyways.</p>
  
  <pre><code>s='abcdef ghij klmn op qrst uv w xy z'
  s=s[::-1]
  print s
  j=0
  p=''
  while(j&lt;len(s)):
      a=''
      while(s[j]!=''):
          a=a+s[j]
          j+=1
      p.append(a[::-1])
      j+=1
  print p
  </code></pre>
  
  <p>It gives me a string index out of range error in the while bracket. Why?</p>
  
  <p>Thanks a lot for the help.</p>