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.
s='abcdef ghij klmn op qrst uv w xy z'
s=s[::-1]
print s
j=0
p=''
while(j<len(s)):
a=''
while(s[j]!=''):
a=a+s[j]
j+=1
p.append(a[::-1])
j+=1
print p
It gives me a string index out of range error in the while bracket. Why?
Thanks a lot for the help.
while(s[j] != '')ever evaluate to false whilejless thanlen(S)? If not, whenjgets to equallen(S).. it'll crash!!