I have two lists,
y1=['fem j sex / male \n', " father's name diwan singh saggu \n", "elector's name rahul saggu \n", 'identity card \n', 'zfk0281501', 'age as on 1.1.2008 23 \n']
word=["sex","father's","name","elector's","name","identity","card","age"]
I need to remove all the strings in y1
which is in word
.
I need to get output as
output=['fem j /male','diwan singh saggu','rahul saggu','zfk0281501','as on 1.1.2008 23']
I have split individual elements in y1 and tried comparing it with word.But i dont know what to do next? How to remove the strings??Here is what i tried,
y1new=[]
for y in y1:
tmp=y.split()
y1new.append(tmp)
for i in y1new:
for j in i:
if j in word:
y1new[i].remove(y1new[i][j])
How can i achieve this?