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:
Ways to Iterate Over a List in Java
Python Tuple index()
Python Program to Convert Decimal to Binary Using Recursion
Python del Statement
Python Program to Randomly Select an Element From the List
Python List remove()
Python Program to Get Line Count of a File
Python Program to Capitalize the First Character of a String
Python Program to Find Hash of File
Python Program to Print Hello world!
Python Sets
Python String center()
Python String translate()
Python exec()
Python id()
Python Artificial Intelligence Project for Beginners - Joshua Eckroth
Python Data Types
Python Multiple Inheritance
Converting a List to String in Java
Python help()
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python map()
Python Dictionary pop()
Python Program to Add Two Matrices
Python Operator Overloading
Python String rstrip()
Debug a JavaMail Program
Python String count()
Python Program to Measure the Elapsed Time in Python
Python Modules
Python Program to Split a List Into Evenly Sized Chunks
Python Program to Print all Prime Numbers in an Interval