Thursday, December 3, 2026 | London 10°C · Drizzle
DailyGlimpse

AI

Python Negative Indexing: Access the Last Element in Seconds

Jyoti Kashyap – Data Analytics Journey 1 min read

Python's negative indexing lets you access elements from the end of a list without needing to know its length. For example, marks = [25, 35, 36, 45, 55] and print(marks[-1]) outputs 55. The index -1 always refers to the last item, -2 to the second last, and so on. This quick tip saves time and makes code more readable—especially when dealing with dynamic lists.

React