Last Updated: February 25, 2016
·
1.516K
· lukasz-madon

Filtering list in-place with for comprehension in Python

my_list[:] = [x for x in my_list if predicate(x)]

Note the [:] after my_list