# Create a sample list images = ['house.png', 'street.png', 'forrest.png']
# Get the last item last = images[-1]
# Print the last item print(last)
forrest.png
The -1 index always returns the last item of a Python list. The -2 index would return the item before the last item, and so on.
Practice what you just learned
Solve Python exercises and get instant AI feedback on your solutions.
Try ActiveSkill for Free →
Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.
