-2

I have the following array:

a1 = [
    0.00646424,
    0.00589349,
    0.00514049,
    0.00516998,
    0.00568154,
    0.00528288,
    0.00503256,
    0.00430429
]

How can I get a subset of this array in a variable where X is the start index and Y is the end index, where I can set X,Y on my own.

For example subset (3,5) would be:

a2= [ 0.00516998, 0.00568154, 0.00528288]

freginold
  • 3,946
  • 3
  • 13
  • 28
Gabrielf1
  • 157
  • 1
  • 2
  • 5

1 Answers1

0

This works:

>>> a = [0.00646424, 0.00589349, 0.00514049, 0.00516998, 0.00568154, 0.00528288, 0.00503256, 0.00430429]
>>> x = 5
>>> y = 9 
>>> a[x:y]
[0.00528288, 0.00503256, 0.00430429]
>>> 
Mohamed Ali JAMAOUI
  • 14,275
  • 14
  • 73
  • 117