Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get last x elements of list python

# To get the last 2 elements in a list you use -2: as position
bikes = ['trek', 'redline', 'giant']
bikes = bikes[-2:]
# Output:
# ['redline', 'giant']

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #elements #list #python
ADD COMMENT
Topic
Name
3+9 =