Last Updated: February 25, 2016
·
1.523K
· 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