I am trying to write my own version of the reversed() function and I don't quite understand how the suggested solution works.
a="sample string"
# my solution
reversed_a=a[len(a):-1:-1]
#suggested solution
reversed_a=[::-1]
Shouldn't [::]
mean [0:len(a)]
? If so, how does it work then? I though it would go from 0 to len(a)
with a step of -1 and raise an exception due to the negative index value.