Trying to find a way to check the following:
approved_countries = ['Germany', 'France']
We have 5 sets:
{'Germany'}
{'Germany', 'France'}
{'Germany', 'France'}
{'Germany'}
{'Germany', 'Italy'}
I need to iterate through the sets and flag the sets that have a country which is not present in the list of approved countries.
So in this case I would need to flag the set that contains Italy.
What would be the most pythonic way of achieving this?
for index,row in enumerate(dataset):
if any([i not in approved_countries for i in row)):
print("Row {} is bad".format(index))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.