Negative numbers mean that you count from the right instead of the left. So, list[-1] refers to the last element, list[-2] is the second-last, and so on.

Answer from Toomai on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ what-is-negative-indexing-in-python
What is Negative Indexing in Python? - GeeksforGeeks
July 23, 2025 - Negative Indexing: Starts from -1 for the last element and goes up to -n for the first element. ... # Using negative indexing in a list a = [10, 20, 30, 40, 50] # Accessing elements from the end print(a[-1]) # last element print(a[-2]) # second ...
Discussions

Negative Indexes in Lists
if you would want the last 3 items without knowing the length of the list. [-3:] More on reddit.com
๐ŸŒ r/learnpython
25
5
October 26, 2024
Negative indexing in Python - Python - Data Science Dojo Discussions
Negative indexes refer to the positions of elements within an array-like object such as a list, tuple, or string, counting from the end of the data structure rather than the beginning. For example, in a list with 5 elements, the last element can be accessed using the index -1, the second to ... More on discuss.datasciencedojo.com
๐ŸŒ discuss.datasciencedojo.com
1
0
November 9, 2022
Changing negative values to 0 in pandas
Iโ€™m new to pandas but wouldnโ€™t a Boolean expression solve your problem? Something like Final[final[:]<0] =0 More on reddit.com
๐ŸŒ r/learnpython
4
1
July 23, 2019
Why does Python begin list numbering from zero?
One reason I don't see mentioned in much detail here: In C/C++, arrays are stored as contiguous blocks of memory, the size of which has to be provided at creation. So, you might see something like int arr[5]; Which means "allocate space for 5 integers, and put the starting location in the variable arr" Technically in this case it's happening on the stack so it's not "allocated" in the same way, so just don't think about that Now, C/C++ has two special operators which do not exist in Python: & (address of) and * (dereference). &foo, as the name suggests, gives you the memory address of the variable foo. Suppose it returns 12304568 - that means that foo's contents are located at the 12304568th byte in memory. *foo gets the value at an address. *(12304568) would look at the 12304568th byte in memory and fetch whatever is there. Not really, since we haven't specified a type, and that address is probably out of bounds and would cause a segmentation fault, so don't think about that either. The code *(&foo) is equivalent to just foo, since we get the address of foo and then get whatever is at that address (the contents of foo). We could also do something like *(&foo + 1). Here, we get the address of foo, then look one unit over, and find whatever's at that location. The unit depends on the type of foo, and scales so that there's no overlap. If foo is an int, then we look 4 bytes over to find the next int. If foo is a double, then we look 8 bytes over to find the next double. So, remember that I said that arr contains the starting location of our block of memory. This means that if we use *arr, we can check whatever is at the first int in our array. We can also look one int over with *(arr + 1). We can do this all the way up until *(arr + 5), where we're no longer looking in our specially-allocated block of memory - we might cause a segmentation fault here. So, what are the elements of our array? *(arr + 0) *(arr + 1) *(arr + 2) *(arr + 3) *(arr + 4) As you might have caught on, this operation is so common that C/C++ has a special syntax for it. arr[n] is (in most compilers) exactly equivalent to *(arr + n) If arrays were 1-indexed in C, then we wouldn't have this symmetry - either arr[n] would be equivalent to *(arr + n - 1), or *arr might produce a segmentation fault. Yuck. Now, I'm just using C for syntax, but the same thing happens under-the-hood in just about every modern programming language I've ever heard of (and the ones I haven't) - even in cases like Python where we don't have direct access to the pointer arithmetic which makes it work. Exceptions to the rule usually break the first rule of symmetry I mentioned - in those languages, arr[n] (or similar subscripting syntax) is equivalent to *(arr + n - 1) (or similar dereferencing syntax). Now, something Python-specific, which is a natural extension of all this, is negative indexes. Did you know in Python that you can use arr[-1] to get the last element of a list? We really have 10 names for a 5-element list in Python: arr[0]; arr[-5] arr[1]; arr[-4] arr[2]; arr[-3] arr[3]; arr[-2] arr[4]; arr[-1] If you know anything about modular arithmetic, this should seem nice to you: each name is congruent mod the length of the list. That is: -5 % 5 == 0 -4 % 5 == 1 -3 % 5 == 2 -2 % 5 == 3 -1 % 5 == 4 You could also think of it as sticking the elements of the list end-to-end, with 0 in the middle: -5 -4 -3 -2 -1 [0 1 2 3 4] a b c d e [a b c d e] This symmetry is also broken if we have 1-indexed arrays. More on reddit.com
๐ŸŒ r/learnpython
94
124
July 9, 2019
๐ŸŒ
AskPython
askpython.com โ€บ python โ€บ list โ€บ negative-indexing
Negative Indexing in Python List - How to Use "-1" Parameter - AskPython
April 4, 2023 - The process of indexing from the opposite end is called Negative Indexing. In negative Indexing, the last element is represented by -1. ... We have a built-in function reverse() in Python to reverse a list, letโ€™s take a look.
๐ŸŒ
EITCA
eitca.org โ€บ home โ€บ how do negative indexes work in python when accessing elements in a list?
How do negative indexes work in Python when accessing elements in a list? - EITCA Academy
August 3, 2023 - In Python, lists are zero-indexed, meaning that the first element is at index 0, the second element at index 1, and so on. Negative indexes, on the other hand, start from -1, where -1 represents the last element in the list, -2 represents the second-to-last element, and so forth.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-negative-index-of-element-in-list
Python - Negative index of Element in List - GeeksforGeeks
July 23, 2025 - It checks each element to see if it matches the target element (ele). When the element is found the negative index is calculated by subtracting the current index from the total length of the list ensuring the result is in negative form.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ negative indexes in lists
r/learnpython on Reddit: Negative Indexes in Lists
October 26, 2024 -

I see how useful using the -1 index can be for lists but is there any world where youโ€™d actually need to use a -3 index (in a list of 4) etc. instead of the zero index? Iโ€™m new to coding so I want to learn as much as possible but Iโ€™m not sure of any case (as of right now) where this would be necessary.

๐ŸŒ
Educative
educative.io โ€บ answers โ€บ what-is-negative-indexing-in-python
What is negative indexing in Python?
Note: Negative indexes start from index number -1, while positive indexes start from index number 0. we can see the same example implemented in the code block below. ... Line 1: We initialize our list that contains 5 elements.
Find elsewhere
๐ŸŒ
Knowledgehills
knowledgehills.com โ€บ python โ€บ negative-indexing-slicing-stepping-comparing-lists.htm
Python Lists โ€“ Negative Indexing, Slicing, Stepping, Comparing, Max and Min โ€“ Knowledge Hills
lst = ['Ajay', 'Bobby','Ashok', 'Vijay', 'Anil', 'Rahul','Alex', 'Christopher'] print (lst[1:]) print (lst[0:]) print (lst[2:-2]) # all elements starting from third element but skips the last two elements. print (lst[::2]) # this will print all alternate elements (begin to end in steps of 2) print (lst[::-1]) # this will print all elements in reverse order ... The first print command will skip the first element and print the entire list whereas the second print command to print lst1[0:] will print the entire list as it is. The third print combines slicing with a negative index.
๐ŸŒ
AlgoCademy
algocademy.com โ€บ link
Negative Index in Python | AlgoCademy
This feature is particularly useful in scenarios where you need to access the last few elements of a list or when iterating through a list in reverse order. Negative indexing in Python allows you to access list elements from the end of the list using negative numbers.
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ python-how-to-use-negative-indexing-in-python-lists-418588
How to use negative indexing in Python lists | LabEx
LabEx encourages continuous practice to improve your Python skills. List slicing allows you to extract a portion of a list using negative indices, providing powerful and flexible data manipulation techniques.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_string_negative_indexing.asp
Python String Negative Indexing
Remove List Duplicates Reverse ... Interview Q&A Python Training ยท โฎ Python Glossary ยท Use negative indexes to start the slice from the end of the string: Get the characters from position 5 to position 1, starting the ...
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ what-is-a-negative-indexing-in-python
What is a Negative Indexing in Python?
August 25, 2023 - Negative indexing in Python allows you to access elements from the end of a sequence (string, list, tuple) by using negative numbers. Instead of counting from the beginning (0, 1, 2...), negative indexing counts backwards from the last element (-1,
๐ŸŒ
Codingem
codingem.com โ€บ home โ€บ negative indexing in python: a step-by-step guide (examples)
Negative Indexing in Python: A Step-by-Step Guide (Examples)
November 1, 2022 - This means the last value of a sequence has an index of -1, the second last -2, and so on. You can use negative indexing as your advantage when you want to pick values from the end (right side) of an iterable.
๐ŸŒ
Medium
medium.com โ€บ @journalehsan โ€บ what-is-negative-indexing-in-python-and-how-to-use-it-34ec7ac5b36
What is Negative Indexing in Python and How to Use It? ๐Ÿ | by Ehsan Tork | Medium
June 9, 2023 - The answer is simple: Python adds the length of the sequence to the negative index to get the corresponding positive index. For example, if you have a list with four elements and you use an index of -1, Python will add 4 (the length of the list) ...
๐ŸŒ
DEV Community
dev.to โ€บ hichem-mg โ€บ negative-indexing-in-python-with-examples-1ind
Negative Indexing in Python, with Examples ๐Ÿ - DEV Community
June 9, 2024 - Negative indexing can be used to dynamically partition lists based on conditions or calculations. This is particularly useful in scenarios like data processing or when working with dynamic datasets.
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ negative index of list in python
Negative Index of List in Python - Spark By {Examples}
May 31, 2024 - How to get a negative index of an element from the list in Python? A negative index of a list in Python refers to accessing elements in a list by counting
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ python-negative-index-of-element-in-list
Python โ€“ Negative index of Element in List
March 26, 2026 - Python allows negative indexing where -1 refers to the last element, -2 to the second last, and so on. In Python, negative indices count backward from the end of the list:
๐ŸŒ
Data Science Dojo
discuss.datasciencedojo.com โ€บ python
Negative indexing in Python - Python - Data Science Dojo Discussions
November 9, 2022 - Negative indexes refer to the positions of elements within an array-like object such as a list, tuple, or string, counting from the end of the data structure rather than the beginning.
๐ŸŒ
YouTube
youtube.com โ€บ watch
Negative Indexing in Python Lists with Example - YouTube
In this video, learn what is Negative Indexing in Python Lists with examples. Lists in Python are ordered. It is modifiable and changeable, unlike Tuples. Py...
Published: August 19, 2022
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ negative indexing in python
What is Negative Indexing in Python? - Be on the Right Side of Change
November 11, 2023 - Negative indexing in Python allows you to access elements from the end of a list or sequence using negative numbers.