About 354,000 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 · Python’s lists are variable-length arrays, not Lisp-style linked lists. The implementation uses a contiguous array of references to other objects, and keeps a pointer to …

  5. python - Delete Function - Stack Overflow

    The exact same thing, namely a function object, is being passed to delete_function. But what you actually want to remove is the association between the name foo or bar and that object -- and …

  6. python - How do I remove duplicates from a list, while preserving …

    How do I remove duplicates from a list, while preserving order? Using a set to remove duplicates destroys the original order. Is there a built-in or a Pythonic idiom?

  7. python - Is there a way to delete created variables, functions, etc ...

    Oct 24, 2014 · I just didn't know that there is a del function out there. I'm beginning to learn Python and often have to experiment in the shell, so standard variable names like x or y are …

  8. python - Remove all whitespace in a string - Stack Overflow

    Oct 1, 2016 · I want to eliminate all the whitespace from a string, on both ends, and in between words. I have this Python code: def my_handle(self): sentence = ' hello apple ' sentence.strip() …

  9. 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 …

  10. python remove() function not working - Stack Overflow

    Jun 24, 2015 · 0 learning Python, and for some reason I can't get the python remove function to work. It works when I'm testing it interactively in Python in the console but not when I write a …