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 Set symmetric_difference_update()
Removing all duplicates from a List in Java
Python String lower()
Python List copy()
Python bytes()
Python String join()
Python format()
Python String rsplit()
Python Program to Catch Multiple Exceptions in One Line
Python Program to Check If a String Is a Number (Float)
Python Program to Get a Substring of a String
Python String isalnum()
Python Set difference_update()
Python List remove()
Python Functions
Python complex()
Python Numbers, Type Conversion and Mathematics
Python Program to Print Hello world!
Python iter()
Python String rpartition()
Python Machine Learning Eqution Reference - Sebastian Raschka
Python setattr()
Python Program to Safely Create a Nested Directory
Python Tuple count()
Python Program to Check Leap Year
Python object()
Python Program to Display Calendar
Python Set isdisjoint()
Python callable()
How to Find an Element in a List with Java
Python Generators
Python Program to Print Colored Text to the Terminal