Consider the following code:
def mystr(L):
print(L[0])
return L[-1]
mystery_list = [2,5]
print(mystr(mystery_list))
Output (stdout):
2
5
I figure Python, once it goes into the negative zones, starts counting backwards? Therefore [-1] is the last element, [-2] is the second last element. Am I correct in this?
Does this behavior exist elsewhere in Python (ie: strings)?
If I create a copy of this list and I started at a negative number to 0 - will the list be inverted? ie newList = [-1:0] <-- will this invert the list?
Thanks.