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 String expandtabs()
Python Program to Find the Square Root
Python enumerate()
Python Modules
Python Anonymous / Lambda Function
Python String istitle()
Python while Loop
Python Program to Print Colored Text to the Terminal
Python bytes()
Finding Max/Min of a List or Collection
Python Machine Learning Second Edition - Sebastian Raschka & Vahid Mirjalili
Python all()
Python Program to Transpose a Matrix
Python frozenset()
Python Program to Differentiate Between del, remove, and pop on a List
Python Dictionary update()
Python Shallow Copy and Deep Copy
Python String rindex()
Python Data Types
Python Program to Represent enum
Python Program to Find Armstrong Number in an Interval
Python List extend()
Python eval()
Python id()
Python Program to Check Leap Year
Python Artificial Intelligence Project for Beginners - Joshua Eckroth
Python Program to Display the multiplication Table
Using a List of Values in a JdbcTemplate IN Clause
Python Program to Append to a File
Python Program to Find the Sum of Natural Numbers
Python Program to Convert Celsius To Fahrenheit
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...