Custom Search

Tuesday, March 22, 2011

python exclude items from list

python Django exclude items from list

---------------------------

>>> k = [2,4,7,5]

>>> k.remove(7)

>>> k
[2, 4, 5]

---------------------------

>>> k = [2,4,7,5]

>>> a = [2,4]

>>> [k.remove(x) for x in a]
[None, None]

>>> k
[7, 5]


---------------------------

No comments:

Post a Comment