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 www.howtouselinux.com #
 
PREVIOUS NEXT
Tagged: #elements #list #python
ADD COMMENT
Topic
Name
8+6 =