I have two arrays initialized like so:
bins = [['1'], ['2'],...['10']]
tasks = ['1:x', '1:y', '2:x', '2:y', '2:z'.... '10:x', '10:y']
I was trying to iterate through [tasks] and compare the string value before ':' to each element in [bins], and if it matches append tasks[i] to bins[i]. So I am expecting bins to be updated like so:
bins = [[1, 1:x, 1:y]...[10, 10:x, 10:y]]
Then I thought it made sense to split off the content before the ':' in [tasks] to compare effectively, so
I split off the contents of [tasks] before the ':' and created a new array:
splits = ['1', '1', '2', '2', .....'10', '10']
Now in my code I am actually iterating through [splits] and trying to append tasks[i] if splits[i] is in bins[i], using the code below:
for i in range(len(splits)):
if (splits[i] in bins[i]) == True:
bins[i].extend(tasks[i])
The problem is the code above does not find any matches (never returns a True), and thus bins[i] is not updated.
Am I not iterating through my arrays correctly? Am I not comparing correctly? How can I compare the first element of [bins] to each element of [splits] until it does not match and move onto the next element of bins[i] and repeat?