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 Program to Count the Occurrence of an Item in a List
Python Program to Shuffle Deck of Cards
Python round()
Python String istitle()
Python datetime
Python Program to Find Hash of File
Python Set difference()
Python String translate()
Python Tuple
Python String swapcase()
Python Dictionary fromkeys()
Python String title()
Python Program to Count the Number of Occurrence of a Character in String
Python String split()
Python hex()
Introduction to Scientific Programming with Python - Joakim Sundnes
Python Program to Make a Flattened List from Nested List
Python String ljust()
Python abs()
Python Machine Learning Second Edition - Sebastian Raschka & Vahid Mirjalili
Python callable()
Python locals()
Python format()
Copy a List to Another List in Java
Python Program to Check if a Number is Positive, Negative or 0
Python Program to Represent enum
Python issubclass()
Python String partition()
Python String isalnum()
Python Objects and Classes
Python String isdigit()
Python 3 for Absolute Beginners - Tim Hall & J.P Stacey