An alternative to the rather unintuitive [::-1]
syntax is this:
>>> test = "abcba"
>>> test == ''.join(reversed(test))
True
The reversed
function returns a reversed sequence of the characters in test
.
''.join()
joins those characters together again with nothing in between.