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 Input, Output and Import
Python Numbers, Type Conversion and Mathematics
Python Set pop()
Python Program to Find Armstrong Number in an Interval
Python Program to Append to a File
Python Dictionary keys()
Python Program to Create Pyramid Patterns
Python String rpartition()
Using a List of Values in a JdbcTemplate IN Clause
Python time Module
Python Program to Extract Extension From the File Name
Python List reverse()
Python Program to Check Prime Number
Python List count()
Python Set update()
How to Convert List to Map in Java
Python Statement, Indentation and Comments
Python Set remove()
Python Set issubset()
Python Dictionary fromkeys()
Python Program to Add Two Matrices
Python Program Read a File Line by Line Into a List
Python String capitalize()
Python Modules
Python String title()
Python Machine Learning Eqution Reference - Sebastian Raschka
Python String find()
Python while Loop
Python Program to Print all Prime Numbers in an Interval
Python bool()
Python String isidentifier()
Python abs()