dimanche 8 décembre 2019

Check if both items in list are not in another list

I want to check if home['team']['division']['name'] and away['team']['division']['name'] are both not in the list divisions = ['Pacific', 'Central']

I thought I would be able to do it with all() but can't seem to work it out.

Some things I tried are:

if not all(x == y for y in divisions for x in [home['team']['division']['name'], away['team']['division']['name']]):

if all(x != y for y in divisions for x in [home['team']['division']['name'], away['team']['division']['name']]):

I also tried using sets but I'm unfamiliar with them and couldn't work that out either.

Aucun commentaire:

Enregistrer un commentaire