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 frozenset()
Converting Iterator to List
Python staticmethod()
Debug a JavaMail Program
Python Program to Reverse a Number
Python format()
Python Closures
Python Program to Measure the Elapsed Time in Python
Python __import__()
Python globals()
Python Program to Count the Number of Occurrence of a Character in String
Python String isspace()
Using a List of Values in a JdbcTemplate IN Clause
Python Set issubset()
Python Numbers, Type Conversion and Mathematics
Python pow()
Python Program to Display the multiplication Table
Python Tuple index()
Natural Language Processing with Python - Steven Bird & Ewan Klein & Edward Loper
Python sorted()
Python property()
Deep Learning with Python - Francois Chollet
Python Program to Transpose a Matrix
How to get current date and time in Python?
Python List reverse()
Python Program to Print Colored Text to the Terminal
Python hash()
Python Program to Calculate the Area of a Triangle
Python Program to Slice Lists
Removing all duplicates from a List in Java
Python Functions
Python for Loop