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 Create a Long Multiline String
Python String strip()
Python frozenset()
Python *args and **kwargs
Deep Learning with Applications Using Python - Navin Kumar Manaswi
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python Package
Python isinstance()
Python while Loop
Python Set issuperset()
Python Program to Slice Lists
Python bytearray()
Python Program Read a File Line by Line Into a List
Python pow()
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python Program to Create a Countdown Timer
Python Program to Merge Mails
Python int()
Python Sets
Python String lower()
Python Deep Learning - Valentino Zocca & Gianmario Spacagna & Daniel Slater & Peter Roelants
Python bytes()
Python Program to Differentiate Between type() and isinstance()
Python List extend()
Python String isspace()
Python hash()
Python issubclass()
Python Program to Transpose a Matrix
Python Program to Add Two Matrices
Python Multiple Inheritance
Python time Module
Python Machine Learning Cookbook - Practical solutions from preprocessing to Deep Learning - Chris A...