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
Written by lukas
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#