I have about a list of lists and I want to check if an element in one list matches any other element. For example I have a list of lists:
lists = [['12','sam'],['13','dan'],['15','dan'],['12','john']]
My question is I want to loop through this list of lists to check whether the element in the second position e.g. 'sam'
is the same as any other element in the second position. If there isn't a match, return the full list.
Example output:
lists = [['12', 'sam'], '12','john']]