I want to get the last 5 elements of a list, but there is no guarantee that the list is at least 5 elements long. I could add a manual check and such, but it seems like I don't have to (the code appears to be working well) when using negative indexing.
Just wanted to make sure I don't get any unexpected behavior/memory leaks, since the code seems to work just fine, and I can't find much documentation on using negative indexing past the usual -1 or -2 cases.
Example of what I mean:
mylist = [2, 3, 4]
print(mylist[-5:])
Output:
[2, 3, 4]