I have project wherein I have to get the index of certain element in a list, then use that index to get another value in another list.
For example,
j_set = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
on_going = [1]
e_list = [[], [1], [1], [2], [3], [3], [5], [4, 7], [6], [8, 9], [10]]
So far, the code looks like this:
if isinstance(on_going, int):
on_going = [on_going]
idx = [y for y, x in enumerate(e_list) if x in on_going] # code to get index in e_list
print(idx)
for i in idx:
q_active = j_set.append(i)
print(q_active)
The objective is to get the corresponding index of value/element in on_going from e_list. Then, use that index to get corresponding activity from j_set and store in q_active.
Expected output:
q_active = [2, 3]
The problem is, with the code above, I am getting an output for storing values in q_active as:
[1, 2] #idx output
None
None
Any help would be appreciated! Thanks!