lundi 29 mai 2017

Most pythonic way to select at random an element in a list with conditions

I have two list:

list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list2 = [1, 4, 5]

I want to select an element from list1 but it shouldn't belongs to list2.

I have a solution using a while loop but I would like to have a one liner more pythonic and elegant.




Aucun commentaire:

Enregistrer un commentaire