0

I would like to create a list from 0 to 11 with starting point 6 and that runs all the range of numbers to obtain the following output:

[6,7,8,9,10,11,0,1,2,3,4,5]

I would like to know if there was an array creation routine to do so: Something like:

range(start=7,stop=6,step=1)
JamesHudson81
  • 2,215
  • 4
  • 23
  • 42

3 Answers3

2

Does this fulfill your needs?

import numpy as np

ar = np.arange(12)
ar = np.roll(ar, 6)

# or np.roll(np.arange(12), 6)

print(ar)

Returns:

array([ 6,  7,  8,  9, 10, 11,  0,  1,  2,  3,  4,  5])
Anton vBR
  • 18,287
  • 5
  • 40
  • 46
2

Simple way to generate list would be like:

a = list(range(6, 12))+list(range(0, 6))
print(a)
xanjay
  • 561
  • 6
  • 20
1

If you just want an ordinary Python list, you can form it from two ascending lists like so:

>>> list(range(6, 12)) + list(range(6))
[6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5]
>>> 
Tom Karzes
  • 22,815
  • 2
  • 22
  • 41