In this example, you will learn to get the last element of this list.
To understand this example, you should have the knowledge of the following Python programming topics:
Using negative indexing
my_list = ['a', 'b', 'c', 'd', 'e'] # print the last element print(my_list[-1])
Output
e
When you use negative indexing, the counting starts from 1 not 0 as shown in the figure below.

If you want the first 1st element, you can use my_list[-5]
.
If you want to learn more, please go to Python list Negative Indexing.
Related posts:
Python Dictionary keys()
Python open()
Python pow()
Python Program to Remove Duplicate Element From a List
Python callable()
Python @property decorator
Python Object Oriented Programming
Python Set difference()
Python dict()
Python Program to Check if a Number is Positive, Negative or 0
Python Set symmetric_difference()
Python eval()
Python str()
Python String find()
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python List extend()
Python Program to Differentiate Between del, remove, and pop on a List
Python input()
Python divmod()
Python Data Structures and Algorithms - Benjamin Baka
Python Program to Print the Fibonacci sequence
Finding Max/Min of a List or Collection
Python Program to Find Numbers Divisible by Another Number
Python id()
Python String replace()
Python List sort()
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python Operators
Natural Language Processing with Python - Steven Bird & Ewan Klein & Edward Loper
Python Set clear()
Python Set intersection_update()
Python String startswith()