Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1227,12 +1227,13 @@ into a list.


How do you remove multiple items from a list
Comment thread
johnslavik marked this conversation as resolved.
Outdated
--------------------------------------------
How do you remove multiple items from a list?
---------------------------------------------

As with removing duplicates, explicitly iterating in reverse with a
delete condition is one possibility. However, it is easier and faster
to use slice replacement with an implicit or explicit forward iteration.
Here are three variations.::
Here are three variations::

mylist[:] = filter(keep_function, mylist)
mylist[:] = (x for x in mylist if keep_condition)
Expand Down
Loading