About 50 results
Open links in new tab
  1. 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?

  2. 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: >>> …

  3. 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.

  4. python - Best way to remove elements from a list - Stack Overflow

    Feb 2, 2014 · I would like to know what is the best way/efficient way to remove element(s) from the list. There are few functions provided by Python: some_list.remove(value), but ...

  5. 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 take …

  6. 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 should ...

  7. Python: remove odd number from a list - Stack Overflow

    18 Your function is working in another way than you would expect. The for loop takes first element, than second etc., so when you remove one element, others change their positions and can be skipped by …

  8. How remove() function was executed in python? - Stack Overflow

    Mar 25, 2022 · Well wasn't the pop function work that way? Coz remove function has a syntax of List.remove (object). The remove functions will get objects and removes it. It works with objects but …

  9. pop/remove items out of a python tuple - Stack Overflow

    In fact, in the case that the condition is an (unapplied) C function (as in the example I provided), filter is usually faster; generator expressions must execute some python bytecode, but aren't required to …

  10. python - Remove all special characters, punctuation and spaces from ...

    I need to remove all special characters, punctuation and spaces from a string so that I only have letters and numbers.