I want to write something that removes a specific element from an array. I know that I have to for loop through the array to find the element that matches the c
There is an alternative solution to this problem which also deals with duplicate matches.
We start with 2 lists of equal length: emails, otherarray. The objective is to remove items from both lists for each index i where emails[i] == 'something@something.com'.
This can be achieved using a list comprehension and then splitting via zip:
emails = ['abc@def.com', 'something@something.com', 'ghi@jkl.com']
otherarray = ['some', 'other', 'details']
from operator import itemgetter
res = [(i, j) for i, j in zip(emails, otherarray) if i!= 'something@something.com']
emails, otherarray = map(list, map(itemgetter(0, 1), zip(*res)))
print(emails) # ['abc@def.com', 'ghi@jkl.com']
print(otherarray) # ['some', 'details']