I have a code:
dates = []
dates.append(['imie', 'nazwisko'])
dates.append(['test', 'test2'])
How can check if "imie" and "nazwisko" is in dates?
if 'imie' and 'nazwisko' in dates - not work
Thanks for help
Using any and generator expression:
>>> dates = []
>>> dates.append(['imie', 'nazwisko'])
>>> dates.append(['test', 'test2'])
>>> any(('imie' in d and 'nazwisko' in d) for d in dates)
True
UPDATE
You can also use set.issubset as suggested by Jon Clements:
>>> any({'imie', 'nazwisko'}.issubset(d) for d in dates)
True
dates?setsand their operators: docs.python.org/2/library/sets.html