.reverse() returns None
. Therefore you should not be assigning it to a variable.
Use this instead:
stra = 'This is a string'
revword = stra.split()
revword.reverse()
revword=''.join(revword)
I've run the code on IDEOne for you so you can see the output. (Also notice that the output is stringaisThis
; you may want to use ' '.join(revword)
, with a space, instead.)
Also note that the method you have provided only reverses the words, not the text. @ron.rothman provided a link that does detail how to reverse a string in its entirety.