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 difference_update()
Python Program to Access Index of a List Using for Loop
How to Convert List to Map in Java
Statistical Methods for Machine Learning - Disconver how to Transform data into Knowledge with Pytho...
Python String translate()
Python exec()
Python Program to Find the Sum of Natural Numbers
Python String islower()
APIs in Node.js vs Python - A Comparison
Python Program to Print Output Without a Newline
Python Decorators
Python String index()
Python Program to Create a Countdown Timer
Python range()
Python sorted()
Python Set issuperset()
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python Program to Differentiate Between del, remove, and pop on a List
Java List UnsupportedOperationException
Python Program to Convert String to Datetime
Python Dictionary popitem()
Python zip()
Python Get Current time
Python Program to Extract Extension From the File Name
Python str()
Python String count()
Python ord()
Python String casefold()
Python Multiple Inheritance
Python Program to Find Factorial of Number Using Recursion
Python Dictionary setdefault()
Python String split()