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
🌐
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.
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
Python, negative values aren't out of range in list - Stack Overflow
How is this possible that negative values aren't out of range? It should throw IndexError. ... Negative indices index the list backwards (l[-1] == l[len(l) - 1]). More on stackoverflow.com
🌐 stackoverflow.com
November 3, 2013
how do I create a python list with a negative index - Stack Overflow
This page gives you a more technical ... its for range, which is somewhat similar): [...] if step is negative, the last element is the smallest start + i * step greater than stop. Additionally, you are attempting to write to a list at indices of it that don't already exist (never mind the fact that you want them to be negative - negative indices have a special meaning in Python) - this would ... More on stackoverflow.com
🌐 stackoverflow.com
List slicing with negative index
On negative step, the default start and stop are reversed. Start is len-1 stop is 0. More on reddit.com
🌐 r/learnpython
5
2
December 15, 2021
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-negative-index-of-element-in-list
Python - Negative index of Element in List - GeeksforGeeks
July 23, 2025 - For example, we are having a list li = [10, 20, 30, 40, 50] and the given element is 30 we need to fin the negative index of it so that given output should be -3. index() method in Python searches for the first occurrence of a specified element ...
🌐
LabEx
labex.io › tutorials › python-how-to-handle-negative-offsets-in-python-list-manipulation-415476
How to handle negative offsets in Python list manipulation | LabEx
The index range for a Python list with n elements is from -n to n-1. This means that the valid negative indices range from -1 (the last element) to -n (the first element).
🌐
Educative
educative.io › answers › what-is-negative-indexing-in-python
What is negative indexing in Python?
Line 9: We get the ending negative index of the list using the formula (sizeOfList * -1) - 1. We convert the sizeOfList variable to a negative number (-5) by multiplying it by -1 and adding -1 to iterate till -6 because -6 is not included in ...
🌐
AskPython
askpython.com › python › list › negative-indexing
Negative Indexing in Python List - How to Use "-1" Parameter - AskPython
April 4, 2023 - Reduces the lines of code for reversing a list in Python. Makes complex operations easier. Takes minimum time and provides low complexity. In indexing, we use a positive integer inside the index operator (square brackets), but we can use a negative integer to start iterating from the last element called negative indexing.
🌐
W3Schools
w3schools.com › python › gloss_python_string_negative_indexing.asp
Python String Negative Indexing
Remove List Duplicates Reverse a String Add Two Numbers · Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python 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 count from the end of the string: b = "Hello, World!" print(b[-5:-2]) Try it Yourself » ·
Find elsewhere
🌐
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 ...
🌐
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.
🌐
Knowledgehills
knowledgehills.com › python › negative-indexing-slicing-stepping-comparing-lists.htm
Python Lists – Negative Indexing, Slicing, Stepping, Comparing, Max and Min – Knowledge Hills
What do you think will be the output ... the code Run the code Confused? Well, the answer is “Alex”, this is because when you give a negative index number Python counts the element from the right....
🌐
Wordaligned
wordaligned.org › articles › negative-sequence-indices-in-python
Negative Sequence Indices in Python
August 1, 2016 - The power of negative indices increases with slicing. Take a slice of a sequence by supplying begin and end indices. >>> domain = 'wordaligned.org' >>> domain[4:9] 'align' >>> domain[4:-4] 'aligned' >>> digits = list(range(10)) >>> digits [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> digits[3:4] [3] >>> digits[1:-1] [1, 2, 3, 4, 5, 6, 7, 8] Omitting an index defaults it to the end of the sequence.
🌐
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 - Here are some examples and use cases of negative indexing in Python: Getting the last element of a sequence. You can use an index of -1 to get the last element of any sequence. For example: a = [1, 2, 3, 4] # a list of four numbers b = «Hello» ...
🌐
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.

🌐
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 - Using an index that is more negative than the list’s length results in an IndexError.
🌐
Execute Program
executeprogram.com › courses › python-for-programmers › lessons › negative-indexing
Python for Programmers: Negative Indexing
Learn programming languages like TypeScript, Python, JavaScript, SQL, and regular expressions. Interactive with real code examples.
🌐
DEV Community
dev.to › hichem-mg › negative-indexing-in-python-with-examples-1ind
Negative Indexing in Python, with Examples 🐍 - DEV Community
June 9, 2024 - In this tutorial, I will go through what negative indexing is, how it works, and its practical applications in Python programming. ... Indexing is a way to access individual elements from sequences like lists, strings, and tuples in Python.
🌐
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,
🌐
TheLinuxCode
thelinuxcode.com › home › python negative index of element in a list: practical patterns, pitfalls, and real‑world usage
Python Negative Index of Element in a List: Practical Patterns, Pitfalls, and Real‑World Usage – TheLinuxCode
January 10, 2026 - If you compute a negative index n, you can recover the positive index by adding the list length. This identity helps in two practical ways: 1) It confirms that your negative index is in range.