some_list[-1] is the shortest and most Pythonic.

In fact, you can do much more with this syntax. The some_list[-n] syntax gets the nth-to-last element. So some_list[-1] gets the last element, some_list[-2] gets the second to last, etc, all the way down to some_list[-len(some_list)], which gives you the first element.

You can also set list elements in this way. For instance:

>>> some_list = [1, 2, 3]
>>> some_list[-1] = 5 # Set the last element
>>> some_list[-2] = 3 # Set the second to last element
>>> some_list
[1, 3, 5]

Note that getting a list item by index will raise an IndexError if the expected item doesn't exist. This means that some_list[-1] will raise an exception if some_list is empty, because an empty list can't have a last element.

Answer from Sasha Chedygov 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 - The simplest and most efficient method uses negative indexing with a[-1]. In Python, we can use -1 as an index to access the last element directly.
Discussions

Finding last index of some value in a list in Python
v[-1] is the last element of a list or tuple. v[-2] is the second last. The syntax where you're doing v[a:b:c], is known as slice notation. a is the start position, b is the end position, and c is the increment. a and b default to the start and end. c defaults to 1, so... v[::] refers to all elements from start to end. Useful for copying whole content somewhere, as distinct from assigning the list to a new variable. v[::2] refers to every second element v[::-1] is all the element in reverse. v[::-2] is every second element in reverse. v[5:] is all elements from 5 to the end. v[:5] is all elements from the start to < 5, so v[:5] and v[5:] do not overlap. More on reddit.com
🌐 r/learnpython
6
5
August 5, 2024
Is there a way to call the last element of an array (not a list)? I can't find anything on the numpy website. TIA
1M subscribers in the learnpython community. Subreddit for posting questions and asking for general advice about all topics related to learning… More on reddit.com
🌐 r/learnpython
2
6
June 25, 2019
Is it possible to grab the last element of a numpy array with a negative slice?
You can't loop from negative to postive slice values as they don't "wrap". a[-2:2] would also give an empty array. More on reddit.com
🌐 r/learnpython
8
1
December 15, 2021
Last element in an array
Length[0] to mean the last element, IMHO, sounds like a foot-gun for experienced developers. It will make the language "sound like" one that has an array[0], but it really doesn't. Worse: algorithms that are copied without adjusting for the array length will almost but not quite work More on reddit.com
🌐 r/ProgrammingLanguages
89
13
April 22, 2024
🌐
Stack Abuse
stackabuse.com › bytes › python-get-last-n-elements-from-list-array
Python: Get Last N Elements from List/Array
July 17, 2022 - One common use case is to retrieve N elements from the end of a list/array, which we'll show how to do here. In Python, you can retrieve elements using similar syntax as in many other languages, using brackets ([]) and an index. However, this syntax can be extended to optionally specify both ...
🌐
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.

🌐
Vultr
docs.vultr.com › python › examples › get the last element of the list
Python Program to Get the Last Element of the List
December 11, 2024 - The output will display 9. This method is the most straightforward when you know the list contains at least one element. Check if the list is non-empty before accessing its content. Use an if statement to prevent errors such as an IndexError. ... This approach ensures error-free execution by handling empty lists effectively. Understand that list.pop() not only retrieves but also removes the last element from the list.
🌐
TutorialsPoint
tutorialspoint.com › article › python-program-to-get-the-last-item-from-the-array
Python Program to get the last item from the array
March 27, 2026 - The simplest way to get the last element is using negative indexing with [-1] ? # creating array numbers = [11, 12, 13, 14, 15, 16, 17, 18, 19] print("The original array is:", numbers) # get last element using negative indexing result = numbers[-1] ...
🌐
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
Find elsewhere
🌐
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.
🌐
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 - To get the last element of a list in Python, you can use the negative indexing feature of the list data type.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python get the last element of a list
Python Get the Last Element of a List - Spark By {Examples}
May 31, 2024 - Have you ever needed to get the last element of a list in Python, but weren't sure of the best way to do it? There are several different methods you can
🌐
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 - Use list[-1] for getting the last element as it's the most pythonic and efficient approach.
🌐
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 - 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. And that’s ok! It works. However, Python presents a more elegant way of doing this, see:
🌐
freeCodeCamp
freecodecamp.org › news › python-get-last-element-in-list-how-to-select-the-last-item
Python Get Last Element in List – How to Select the Last Item
March 15, 2022 - After using the pop() method, we got the value of the last element printed. But then when we print the list to the console, we can see that the last item no longer exists. In this article, we learned how to select the last item in a list using ...
🌐
PyTutorial
pytutorial.com › last-element-of-array-python
PyTutorial | 3 Methods to Get Last Element of Array in Python
June 13, 2023 - my_array = [10, 20, 30, 40, 50] # Array last_element = my_array[-1] # Get Last Element print(last_element) ... However, using the negative index -1 allows you to access the last element of the array's length easily. Slicing is a Python feature ...
🌐
Reddit
reddit.com › r/learnpython › is it possible to grab the last element of a numpy array with a negative slice?
r/learnpython on Reddit: Is it possible to grab the last element of a numpy array with a negative slice?
December 15, 2021 -

I have an array, a, which can be thought of as symmetric (the beginning holds some vectors, and the end holds their complements).

In order to make my code more tidy, I would like to just use negative indexing to get the original vectors and their complements. However, I can't figure out how to grab the last element of the array with negative indexing. Is this possible?

import numpy as np
start = 1 
stop = 3 
a = np.array([1,2,3,4,5,6,7,8]) 
a[start:stop] 
a[-stop:-start]

This setup works for all situations except where I need to grab the first/last element of the array. When start = 0, it returns an empty array.

🌐
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]) ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-get-first-and-last-elements-of-a-list
Get first and last elements of a list in Python - GeeksforGeeks
Unpacking allows us to extract the first and last elements while ignoring the rest. Using first, *_, last = a gives the first and last elements directly.
Published: July 11, 2025
🌐
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 most effective way to get the last element of a list in Python is using the list[-1]. Python allows you to use negative indices, which count from the end of the list instead of the beginning. So list[-1] gets the last element, list[-2] gets the second to last.
🌐
30 Seconds of Code
30secondsofcode.org › home › python › first, last, initial, head, tail
First, last, initial, head, tail of a Python list - 30 seconds of code
May 15, 2024 - To get the first element of a list ... first([1, 2, 3]) # 1 first([]) # None · To get the last element of a list, you can use lst[-1]. This will return the last element of the list, or None if the list is empty....