example:
random_list = ['foo','foo','foo','foo',56,'foo','foo','foo','foo','foo']
# in random_list there are always 10 elements, one of which is 56, but its position is unknown
def find_index_of_56_in_list_1():
for index in range(0,5):
if 56 == random_list[index]:
return index
def find_index_of_56_in_list_2():
for index in range(6,10):
if 56 == random_list[index]:
return index
I would like to split the computational power of iterating in the list in 2 Thread one for the first half of the list 'find_index_of_56_in_list_1' and the other for the second half of the list 'find_index_of_56_in_list_2'. and if one process has terminated then the other must terminate as well and nothing or return 'none'.
The problem I am trying to solve is not this one but a bigger one, this example is an analogy. I've tried with threading library, but i can't get one process to terminate when the other has terminated or vice versa.