Numpy slicing allows you to input a list of indices to an array so that you can slice to the exact values you want.

For example:

    import numpy as np
    a = np.random.randn(10)
    a[[2,4,6,8]]

This will return the 2nd, 4th, 6th, and 8th array elements (keeping in mind that python indices start from 0). So, if you want every 2nd element starting from an index x, you can simply populate a list with those elements and then feed that list into the array to get the elements you want, e.g:

    idx = list(range(2,10,2))
    a[idx]

This again returns the desired elements (index 2,4,6,8).

Answer from enumaris on Stack Overflow
🌐
NumPy
numpy.org › doc › stable › user › basics.indexing.html
Indexing on ndarrays — NumPy v2.5 Manual
The simplest case of indexing with N integers returns an array scalar representing the corresponding item. As in Python, all indices are zero-based: for the i-th index \(n_i\), the valid range is \(0 \le n_i < d_i\) where \(d_i\) is the i-th element of the shape of the array.
Discussions

Python: using range of indexes of an array in conditions - Stack Overflow
Python newbie here. Let's say we have an array which contains 10 random integers. I want to check if each value of the integers is 0 More on stackoverflow.com
🌐 stackoverflow.com
Using python range objects to index into numpy arrays - Stack Overflow
numpy predates Python 3. In Python 2, range(3) is a list of integers, which numpy treats as "array-like". It would have been a mess if numpy didn't also handle that in a backwards compatible way in Python 3. ... "So, does anybody know why this works at all?" It is a nice feature, informally called "fancy" indexing... More on stackoverflow.com
🌐 stackoverflow.com
Array elements in a specific range and center element of range
Hi Everyone! Nice to see there is an active community here, that offers support to beginners. I have the following problem I am trying to resolve with a roulette wheel program: Input: #First array that contains all the roulette wheel numbers in clockwise order starting from pocket 0: ckwheel ... More on discuss.python.org
🌐 discuss.python.org
3
0
June 18, 2022
numpy.take range of array elements Python - Stack Overflow
I have an array of integers. data = [10,20,30,40,50,60,70,80,90,100] I want to extract a range of integers from the array and get a smaller array. data_extracted = [20,30,40] I tried numpy.take. ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Hpc-carpentry
hpc-carpentry.org › hpc-python › 03-lists › index.html
Numpy arrays and lists – Introduction to High-Performance Computing in Python
January 20, 2023 - Note that in Python, all indices ... position — the first element does not require an offset to get to. ... Note that we can index a range using the colon (:) operator....
🌐
W3Schools
w3schools.com › python › numpy › numpy_array_indexing.asp
NumPy Array Indexing
The second number represents the second dimension, which also contains two arrays: [1, 2, 3] and: [4, 5, 6] Since we selected 1, we are left with the second array: [4, 5, 6] The third number represents the third dimension, which contains three values: 4 5 6 Since we selected 2, we end up with the third value: 6 · Use negative indexing to access an array from the end.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-array-indexing
Python Array Indexing - GeeksforGeeks
July 1, 2026 - Each element has a position called an index, which allows you to access it directly without traversing the entire array. ... Python arrays use zero-based indexing, so counting starts from 0.
🌐
Quora
quora.com › How-do-I-select-a-range-of-numbers-in-an-array-in-Python
How to select a range of numbers in an array in Python - Quora
Answer (1 of 2): [code]import numpy as np a = np.arange(1, 11) #Creating an array of 10 elements print(a) [/code]Now if you want elements from index 2 to 5(remember indexing starts from 0), so basically we want elements 3, 4, 5 and 6. For this use: [code]a[2:6] [/code] > a[ index you want to sta...
Find elsewhere
🌐
IQCode
iqcode.com › code › python › python-array-index-range
python array index range Code Example
a[start:stop] # items start through stop-1 a[start:] # items start through the rest of the array a[:stop] # items from the begin...
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python array index
Python Array Index - Spark By {Examples}
May 31, 2024 - Python Array index is commonly used to refer to the index of an element within an array. You can use array indexing to manipulate and access array
🌐
Omz Software
omz-software.com › pythonista › numpy › reference › arrays.indexing.html
Indexing — NumPy v1.8 Manual
The simplest case of indexing with N integers returns an array scalar representing the corresponding item. As in Python, all indices are zero-based: for the i-th index n_i, the valid range is 0 \le n_i < d_i where d_i is the i-th element of the shape of the array.
🌐
i-Programmer
i-programmer.info › programming › python › 3942-arrays-in-python.html
Arrays in Python
March 19, 2012 - Programming book reviews, programming tutorials,programming news, C#, Ruby, Python,C, C++, PHP, Visual Basic, Computer book reviews, computer history, programming history, joomla, theory, spreadsheets and more.
🌐
Railsware
railsware.com › home › engineering › indexing and slicing for lists, tuples, strings, other sequential types in python
Python Indexing and Slicing for Lists, Tuples, Strings, other Sequential Types | Railsware Blog
January 22, 2025 - Python supports slice notation for any sequential data type like lists, strings, tuples, bytes, bytearrays, and ranges. Also, any new data structure can add its support as well. This is greatly used (and abused) in NumPy and Pandas libraries, which are so popular in Machine Learning and Data Science. It’s a good example of “learn once, use everywhere”. In this article, we will focus on indexing and slicing operations over Python’s lists.
🌐
NumPy
numpy.org › devdocs › user › basics.indexing.html
Indexing on ndarrays — NumPy v2.6.dev0 Manual
The simplest case of indexing with N integers returns an array scalar representing the corresponding item. As in Python, all indices are zero-based: for the i-th index \(n_i\), the valid range is \(0 \le n_i < d_i\) where \(d_i\) is the i-th element of the shape of the array.
🌐
Python.org
discuss.python.org › python help
Array elements in a specific range and center element of range - Python Help - Discussions on Python.org
June 18, 2022 - I have the following problem I ... 0: ckwheel = np.array([ 0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29, 7, 28, 12, 35, 3, 26 ]) There is a second array ...
🌐
Jeff Stafford
jstaf.github.io › hpc-python › lists
Lists and arrays — HPC Python
Note that in Python, all indices ... position - the first element does not require an offset to get to. ... Note that we can index a range using the colon (:) operator....
🌐
Tutorialspoint
tutorialspoint.com › python › python_array_index_method.htm
Python Array index() Method
import array as arr my_arr3 = arr.array('d',[1.4,2.9,6.6,5.9,10.5,3.4]) x = 34 #searching the element with in given range index = my_arr3.index(x) print("The index of the element", x, "within the given range", ":",index)
🌐
Guru99
guru99.com › home › python › python range() function: float, list, for loop examples
Python range() Function: Float, List, For loop Examples
July 10, 2026 - In case the start index is not given, the index is considered as 0, and it will increment the value by 1 till the stop index. For example, range(5) will output the values 0, 1, 2, 3, 4. The Python range() is a very useful command and is mostly used when you have to iterate using a for loop.