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 Numbers, Type Conversion and Mathematics
Python format()
Python next()
Applied Text Analysis with Python - Benjamin Benfort & Rebecca Bibro & Tony Ojeda
Python Dictionary items()
Python String casefold()
Python List
Remove the First Element from a List
Python Program to Copy a File
Python Program to Find ASCII Value of Character
Python Program to Check if a Number is Odd or Even
Python String startswith()
Python property()
Python globals()
Python Errors and Built-in Exceptions
Python String upper()
Python Set isdisjoint()
Python Program to Check Armstrong Number
Introduction to Scientific Programming with Python - Joakim Sundnes
Python String rpartition()
Python String translate()
Python Program to Safely Create a Nested Directory
Deep Learning in Python - LazyProgrammer
Python __import__()
Converting between an Array and a List in Java
Python Program to Append to a File
Python Set pop()
Python Program to Find the Largest Among Three Numbers
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python String endswith()
Python Program to Display Powers of 2 Using Anonymous Function
Python Strings