Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python extract every nth value from list

# Basic syntax:
new_list = your_list[start_index::spacing]

# Example usage using list slicing:
# Say you have the following list and want every third item
your_list = [0,1,2,3,4,5,6,7,8,9]
new_list = your_list[0::3]

print(new_list)
--> [0, 3, 6, 9]
 
PREVIOUS NEXT
Tagged: #python #extract #nth #list
ADD COMMENT
Topic
Name
4+2 =