I have 2 lists. The first is list_A = ['Sasi', 'Babu', 'kuttapppan', 'mathayi']
and my second list is list_B = ['Raman', 'Kesavan', 'sasi', 'unni', 'Kuttappan']
.
I want to compare these two lists and identify the values which are duplicated in the second list regardless of if it starts with a capital letter or a lowercase letter. I've tried the following method:
if not [name for name in list_A if name in list_B]:
print name
But it is not working as expected.
#Might be better if we are dealing with huge lists.
list_A = ['Sasi', 'Babu', 'kuttapppan', 'mathayi']
list_B = ['Raman', 'Kesavan', 'sasi', 'unni', 'Kuttappan'].
d = [x.lower() for x in list_A] # make dict of list with less elements
for m in list_B: # search against bigger list
if m.lower() in d: print(m)