[Tutor] string reversal using [::-1]
Vikas YADAV
vikasy at gmail.com
Sat Jun 10 12:39:57 EDT 2017
Question: Why does "123"[::-1] result in "321"?
MY thinking is [::-1] is same as [0:3:-1], that the empty places defaults to
start and end index of the string object.
So, if we start from 0 index and decrement index by 1 till we reach 3, how
many index we should get? I think we should get infinite infinite number of
indices (0,-1,-2,-3.).
This is my confusion.
I hope my question is clear.
Thanks,
Vikas
More information about the Tutor
mailing list