Q:

Python sentence reverser

I am trying to create a program in python in which the user enters a sentence and the reversed sentenced is printed. The code I have so far is:
sentence = raw_input('Enter the sentence')
length = len(sentence)

for i in sentence[length:0:-1]:
    a = i
    print a,

When the program is run it misses out the last letter so if the word was 'hello' it would print 'olle'. Can anyone see my mistake?

A:

You need to remove the 0 from your indices range, but instead you can use :
sentence[length::-1]

Also not that then you don't need to loop over your string and use extra assignments and even the length you can simply print the reversed string. 
So the following code will do the job for you  :
print sentence[::-1]

Demo :
>>> s="hello"
>>> print s[::-1]
'olleh'

