I have something like this:
input: [['5', '-1'], ['3', '5'], ['6', '3'], ['7', '3']]
and the code is '5'
. Output should be: [['6', '3'], ['7', '3']]
. So all elements that had a code were removed. I've tried doing something like this:
parent_ids = [['5', '-1'], ['3', '5'], ['6', '3'], ['7', '3']]
print(parent_ids)
code = '5'
for parent_id in parent_ids:
print(parent_id)
for sublist in parent_id:
if code in sublist:
parent_ids.remove(parent_id)
But I get [['3', '5'], ['6', '3'], ['7', '3']]
which is not 100% correct, it removed only 1 element