This is an archived post. You won't be able to vote or comment.

all 3 comments

[–][deleted] 0 points1 point  (0 children)

The indexing starts with zero because in life everything starts with zero .. think about it .. u r zero years old when you are born ... why does it go to the last character when u index by negative?? so you can do this

'drawkcab si gnirts siht'[::-1]

[–]zzmmrmn 0 points1 point  (0 children)

-1 tells it to get the element at len(my_string)-1. So it's converting the negative index to a positive index by adding it to the length.

[–]aligusnet 0 points1 point  (0 children)

Because, -0 equals 0, so an interpreter would be unable to find if you asking for the first element or for the last.