I need to visit items in array starting to index random.
My code
from random import randrange
fruits = ['banana', 'apple', 'mango']
index = randrange(len(fruits))
for index in fruits[index:]:
print index
It is possible when index is 1 or 2 after to print start again in index 0 or 1 in that loop for.
Example:
Randon index is 1 print = 'apple' 'mango' 'banana'
Randon index is 2 print = 'mango' 'apple' 'banana'
index, which is going to screw you up. Second, you should be able to use the%modulus operator to get that working, I would think.