About 826,000 results
Open links in new tab
  1. Best way to remove elements from a list - Stack Overflow

    Feb 2, 2014 · Scenarios: If you have few items to remove say one element or between 1 to 5. If you have to remove multiple items in a sequence. If you have to remove different items based …

  2. The most efficient way to remove the first N elements from a list

    Mar 23, 2025 · I need to remove the first N elements from a list of objects. Is there an easy way, without using loops?

  3. Remove list from list in Python - Stack Overflow

    Sep 17, 2016 · Possible Duplicate: Get difference from two lists in Python What is a simplified way of doing this? I have been trying on my own, and I can't figure it out. list a and list b, the …

  4. Remove all the elements that occur in one list from another

    Nov 18, 2010 · 819 Python has a language feature called List Comprehensions that is perfectly suited to making this sort of thing extremely easy. The following statement does exactly what …

  5. python - How to remove items from a list while iterating ... - Stack ...

    Oct 23, 2012 · I'm iterating over a list of tuples in Python, and am attempting to remove them if they meet certain criteria. for tup in somelist: if determine(tup): code_to_remove_tup What …

  6. Remove all occurrences of a value from a list? - Stack Overflow

    Jul 21, 2009 · In Python remove() will remove the first occurrence of value in a list. How to remove all occurrences of a value from a list? This is what I have in mind: >>> …

  7. How to remove an element from a list by index - Stack Overflow

    Dec 13, 2016 · How do I remove an element from a list by index? I found list.remove(), but this slowly scans the list for an item by value.

  8. python - Remove all values within one list from another list?

    For modification (remove method) - average time is 252 seconds For set approach - average time is 0.75 seconds So you can see that approach with sets is significantly faster than others. Yes, …

  9. python - Removing duplicates in lists - Stack Overflow

    Nov 1, 2011 · In fact, despite the title "Python removing duplicates in lists", it doesn't seem like OP wanted to remove duplicates from within the same list at all. Rather, it looks like OP wanted to …

  10. Difference between del, remove, and pop on lists in Python

    Related post on similar lines for set data structure - Runtime difference between set.discard and set.remove methods in Python?