Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

list get every 2nd element

a_list = [0, 1, 2, 3]

n = 2
every_second_element = a_list[::n]
# Get every 2nd element of `a_list`

print(every_second_element)
# OUTPUT
# [0, 2]
 
PREVIOUS NEXT
Tagged: #list #element
ADD COMMENT
Topic
Name
9+6 =