len(list1)-1 is definitely the way to go, but if you absolutely need a list that has a function that returns the last index, you could create a class that inherits from list.

class MyList(list):
    def last_index(self):
        return len(self)-1


>>> l=MyList([1, 2, 33, 51])
>>> l.last_index()
3
Answer from Austin Marshall on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-how-to-get-the-last-element-of-list
Get the Last Element of List in Python - GeeksforGeeks
July 11, 2025 - Explanation:len(a) - 1 gives the index of the last item, which is then used to retrieve the value. We can also find the last element by using len() function.
Discussions

Finding first and last index of some value in a list in Python - Stack Overflow
0 How to find the index of the first instance of a list (in a list) containing the wanted value (in Python)? 0 How to get index of the last item with a given value More on stackoverflow.com
🌐 stackoverflow.com
python - How do I get the last element of a list? - Stack Overflow
Copy>>> empty_list[-1] Traceback ... list index out of range · But again, slicing for this purpose should only be done if you need: ... As a feature of Python, there is no inner scoping in a for loop. If you're performing a complete iteration over the list already, the last element will still ... More on stackoverflow.com
🌐 stackoverflow.com
Why is the index -1 always denoted as the last element of a list in python?
You can count backwards from the end like this. -1 is the last item, and -2 is the second to last item, etc. More on reddit.com
🌐 r/learnpython
7
1
February 25, 2022
Second occurrence index number from list.
I think its not well known that the list.index method takes optional start and stop arguments: >>> help(list.index) Help on method_descriptor: index(self, value, start=0, stop=9223372036854775807, /) Return first index of value. Raises ValueError if the value is not present. So perhaps the simplest way to accomplish this would be something like: nums = [1, 2, 3, 4, 1, 2, 3, 4] first = nums.index(2) second = nums.index(2, first + 1) print(nums[:second]) More on reddit.com
🌐 r/learnpython
16
3
March 15, 2022
🌐
Reddit
reddit.com › r/learnpython › finding last index of some value in a list in python
r/learnpython on Reddit: Finding last index of some value in a list in Python
August 5, 2024 -

Let's say v is a list or a tuple.

To find the last occurrence of value in v we would need to compute len(v) - 1 - v[::-1].index(value)

Why is this? Why must we subtract the last term from len(v) - 1? Why does simply writing v[::-1].index(value) give the wrong result?

In fact, what does v[::-1] actually do? Doesn't it reverse the list/tuple? If it does reverse it, then v[::-1].index(value) should give the last occurrence of value in v, but for some reason it does not work like that.

🌐
Sentry
sentry.io › sentry answers › python › get the last element of a list in python
Python Last Element in List Using Negative Indexing | Sentry
July 3, 2026 - Access the last element of a Python list using negative index notation with [-1], which counts positions from the end of the list instead of the start
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-last-occurrence-of-some-element-in-a-list
Last Occurrence of Some Element in a List - Python - GeeksforGeeks
July 11, 2025 - For example, w = ["apple", "banana", "orange", "apple", "grape"] we need to find last occurrence of string 'apple' so output will be 3 in this case. rindex() method in Python returns the index of the last occurrence of an element in a list.
🌐
Jessica Temporal
jtemporal.com › the-last-of-a-list-in-python
Getting the last element of a list in Python | Jessica Temporal
June 20, 2026 - Coming from other languages like ... more or less like this to get the last element of a list: Use the len() size function to get the length of the list and subtract 1 to get the index of the last element in that list...
Top answer
1 of 10
165

Sequences have a method index(value) which returns index of first occurrence - in your case this would be verts.index(value).

You can run it on verts[::-1] to find out the last index. Here, this would be len(verts) - 1 - verts[::-1].index(value)

2 of 10
53

Perhaps the two most efficient ways to find the last index:

def rindex(lst, value):
    lst.reverse()
    i = lst.index(value)
    lst.reverse()
    return len(lst) - i - 1
import operator

def rindex(lst, value):
    return len(lst) - operator.indexOf(reversed(lst), value) - 1

Both take only O(1) extra space and the two in-place reversals of the first solution are much faster than creating a reverse copy. Let's compare it with the other solutions posted previously:

def rindex(lst, value):
    return len(lst) - lst[::-1].index(value) - 1

def rindex(lst, value):
    return len(lst) - next(i for i, val in enumerate(reversed(lst)) if val == value) - 1

Benchmark results, my solutions are the red and green ones:

This is for searching a number in a list of a million numbers. The x-axis is for the location of the searched element: 0% means it's at the start of the list, 100% means it's at the end of the list. All solutions are fastest at location 100%, with the two reversed solutions taking pretty much no time for that, the double-reverse solution taking a little time, and the reverse-copy taking a lot of time.

A closer look at the right end:

At location 100%, the reverse-copy solution and the double-reverse solution spend all their time on the reversals (index() is instant), so we see that the two in-place reversals are about seven times as fast as creating the reverse copy.

The above was with lst = list(range(1_000_000, 2_000_001)), which pretty much creates the int objects sequentially in memory, which is extremely cache-friendly. Let's do it again after shuffling the list with random.shuffle(lst) (probably less realistic, but interesting):

All got a lot slower, as expected. The reverse-copy solution suffers the most, at 100% it now takes about 32 times (!) as long as the double-reverse solution. And the enumerate-solution is now second-fastest only after location 98%.

Overall I like the operator.indexOf solution best, as it's the fastest one for the last half or quarter of all locations, which are perhaps the more interesting locations if you're actually doing rindex for something. And it's only a bit slower than the double-reverse solution in earlier locations.

All benchmarks done with CPython 3.9.0 64-bit on Windows 10 Pro 1903 64-bit.

Find elsewhere
🌐
Finxter
blog.finxter.com › home › learn python blog › how to get the last element of a python list?
How to Get the Last Element of a Python List? - Be on the Right Side of Change
September 27, 2020 - To access the last element of a Python list, use the indexing notation list[-1] with negative index -1 which points to the last list element. To access the second-, third-, and fourth-last elements, use the indices -2, -3, and -4. To access the n last elements of a list, use slicing list[:-n-1:-1] ...
🌐
How to Use Linux
howtouselinux.com › home › 3 ways to get last element of a list in python
3 Ways to Get Last Element of a List In Python - howtouselinux
October 9, 2025 - The first element in a list will ... sequence of objects in square brackets ([]). So, if we want to get the last element in a list, we can just use index -1....
🌐
Stack Abuse
stackabuse.com › python-get-last-element-in-list
Python: Get Last Element in List
March 2, 2023 - lastElement = exampleList[-1] print("Last element: ", lastElement) print("exampleList: ", exampleList) secondToLast = exampleList[-2] print("Second to last element: ", secondToLast) ... Negative indexing does not change the original list. It is only a way of accessing elements without any changes ...
🌐
YouTube
youtube.com › shorts › 7TqWU_VjwPA
How To Find The Last Index Of An Item In A Python List - YouTube
November 30, 2025 - This video shows how to find the last index of an item in a Python list. This video is needed because regular list index method only returns the first index ...
🌐
TutorialsPoint
tutorialspoint.com › How-to-get-the-last-element-of-a-list-in-Python
How to get the last element of a list in Python?
August 23, 2023 - List slicing with [-1:] returns a new list containing only the last element. To get the element itself, access index [0] of the result.
🌐
Better Stack
betterstack.com › community › questions › how-to-get-last-element-in-list-in-python
How do I get the last element of a list in Python? | Better Stack Community
January 26, 2023 - You can also use the len() function to get the length of the list and use it to index the last element. For example: ... Both of these approaches will work regardless of the length of the list.
🌐
Delft Stack
delftstack.com › home › howto › python › get last element of list in python
How to Get Last Element of List in Python | Delft Stack
February 15, 2024 - The following code example shows us how we can get the last element of a list with the pop() function in Python. list1 = [0, 1, 2, 3, 4] last = list1.pop() print(last) print(list1) ...
🌐
PythonForBeginners.com
pythonforbeginners.com › home › get the last element of a list in python
Get the last element of a list in Python - PythonForBeginners.com
August 11, 2021 - In python, we can use positive indices as well as negative indices. Positive indices start with zero which corresponds to the first element of the list and the last element of the list is identified by the index “listLen-1” where “listLen” is the length of the list.
🌐
Python Shiksha
python.shiksha › home › tips › 7 ways to get the last element of a list in python
7 ways to Get the last element of a list in Python - Python Shiksha
August 1, 2022 - As I have mentioned at he starting that we can simply get the last element by doing list[len-1], but if you are familiar with coding practices, you might me knowing that from the end of a list or array the concept of negative index is used.
🌐
YouTube
youtube.com › shorts › 8JqKYkW8DFo
What Is The Index Of The Last Element In A List Python - YouTube
November 25, 2025 - That video answers what is the index of the last element in a list Python. It shows off an example to answer the question.#python #shorts
🌐
PythonHow
pythonhow.com › how › get-the-last-element-of-a-list
Here is how to get the last element of a list in Python
To get the last element of a list in Python, you can use the index -1.You can also use the pop() method to remove and return the last element of a list. This method removes the element from the list, so if you want to keep the original list intact, you can use the slicing syntax to get a copy ...
🌐
Quora
quora.com › How-do-I-find-the-last-element-of-a-list-in-Python
How to find the last element of a list in Python - Quora
Answer (1 of 3): > lets say we have a list of words [code]words = [‘One’, ‘Hello’, ‘Welcome’] [/code] * One Way to do this, is by counting the negative way. [code]print(words[-1]) # will print 'Welcome' (the answer you want) print(words[-2]) # will print 'Hello' print(words[-3]) ...