Skip to content

How to access the last element of a list in Python?

# To get the last element in a list you use -1 as position
bikes = ['trek', 'redline', 'giant']
# Output:
# 'giant'
See also  Python code snippet - How to run terminal command?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.