I know that the last element of a list say li
can be accessed by li[-1]
but how exactly does it work in the background? Is it same as li[len(li) - 1]
Is there any other way of getting the last element of a list without actually knowing the length of the list? I am looking at this question in terms of efficiency so please suggest any other alternate solutions with less complexity if it exists.