0

I have a position list 2,7,11,15 and i want to through them and to find the range value of every first index value and second index value. Imagine the 2 is the start and 7 is the end and then continue 7 become the start and 11 become the end. i want to get the range of between 2 and 7 and then 7 to 11 and 11 to 15.

what i did :

position[2,7,11,15]



  for index, line in enumerate(position):
    length = range(position[index],position[index+1])
    for n in length:
        print(n)
Gerald
  • 69
  • 8
  • What do you mean by "range value"? please show *exactly* what the output should be, for this input value of `[2, 7, 11, 15]`. – Karl Knechtel Jul 28 '21 at 09:40

1 Answers1

1

If I understand your question properly then it's as simple as this:-

position[2,7,11,15]

for k in range(len(position)-1):
  print(position[k+1]-position[k])