lot = [("a","b","c"),
("a","b","c"),
("a","b","d"),
("a","b","d"),
("i","k","l")]
ft = [("a","b","c"),("a","b","d")]
Используйте in
или not in
для тестирования членства .
>>> for thing in lot:
... if thing in ft:
... print(f'{thing} in ft')
... else:
... ft.append(thing)
('a', 'b', 'c') in ft
('a', 'b', 'c') in ft
('a', 'b', 'd') in ft
('a', 'b', 'd') in ft
>>> ft
[('a', 'b', 'c'), ('a', 'b', 'd'), ('i', 'k', 'l')]
>>>
или используйте наборы для тестирования членства .
>>> set(lot).difference(ft)
{('i', 'k', 'l')}
>>> ft.extend(set(lot).difference(ft))
>>> ft
[('a', 'b', 'c'), ('a', 'b', 'd'), ('i', 'k', 'l')]
>>>