Given the following code:
length = 10 numbers = [x for x in range(length)] start_index = randint(0,length-1) # now output each value in order from start to start-1 (or end) # ex. if start = 3 --> output = 3,4,5,6,7,8,9,0,1,2 # ex if start = 9 ---> output = 9,0,1,2,3,4,5,6,7,8
What is the best / easiest / most pythonic / coolest way to iterate over the list and print each value every time, starting from the beginning and packing to start-1 or end if the random value is 0.
Ex. start = 3 , then output = 3,4,5,6,7,8,9,1,2
I can come up with some ugly ways (try, with the exception of IndexError, for example), but we are looking for something better. Thanks!
EDIT: clarified that the beginning is an index value starting with