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 bytes()
Python Program to Differentiate Between type() and isinstance()
Python Set issuperset()
Python __import__()
Python String title()
Python Program to Print all Prime Numbers in an Interval
Python print()
Python Deeper Insights into Machine Learning - Sebastian Raschka & David Julian & John Hearty
Python Recursion
Python Program to Print Output Without a Newline
Python Program to Find the Factors of a Number
Python Set union()
Python Program to Count the Occurrence of an Item in a List
Python Type Conversion and Type Casting
Python String rindex()
Python Program to Find HCF or GCD
Python String isalpha()
Python Program to Print Colored Text to the Terminal
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar
Python Set symmetric_difference_update()
Python break and continue
Python next()
Python Program to Concatenate Two Lists
Python Program to Display the multiplication Table
Python Deep Learning Cookbook - Indra den Bakker
Python String isprintable()
Python Dictionary keys()
Python memoryview()
Python String startswith()
Python locals()
Python Program to Parse a String to a Float or Int
Python dict()