I didn't know how best to phrase this question since googling and searching here always led me to stuff which was more involved, I am pretty sure this is basic stuff but for the life of me I can't find a nice way to do the following
given an integer series, say
for x in range(0,36):
I want to link these indices to different lists, the first one is easy it's 1/6th of the main list, so I can use
int(n/6)
to get 6 sets of 0,1,2,3,4,5 mapped to my series
but if I want a series which alternates 0,0,1,1, (repeat) what's the simplest way to do this (so not just an odd/even check with alternating 0s/1s, since the list I am mapping to has 2 values in it, but the original list of 36 items repeats these items, so each 2 rows should map to the same thing
I'm too embarassed to post the steaming pile of nonsense I've tried so far.
to clarify, the left number is my ranged index, the right number is what I want to get based on the index
- 0,0 (will map to 1st item in a list of 2 items)
- 1,0 (will also map to 1st item in a list of 2 items)
- 2,1 (will map to 2nd item in a list of 2 items)
- 3,1 (will also map to 2nd item in a list of 2 items)
- 4,0 etc
- 5,0
- 6,1
- 7,1
- 8,0
- 9,0
- etc
list(itertools.islice(itertools.cycle([0, 0, 1, 1]), 36))
? - Mechanic Pig