About 50 results
Open links in new tab
  1. How do I remove the first item from a list? - Stack Overflow

    Dec 13, 2010 · In fact, the first sentence is misleading, because you cannot remove the i'th element with list.remove(a[i]). With duplicate values, it may find an earlier element with the same value, and …

  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. Deleting first element of a list in Python - Stack Overflow

    Mar 26, 2017 · I am aware that if I wish to delete only the first element of a list t in Python I can do it with : del t [0] which is about as straightforward as it gets. However : t = t [1:] also works.

  4. python - How to remove the first and last item in a list ... - Stack ...

    Jul 5, 2012 · You don't want to remove the first and the last element of a list. According to your description you want to remove the first and the last block of characters from a space-separated …

  5. python - How do I remove the first element in a list within a list ...

    1 You can do it with iterating over the list, and then call the pop () function on the inner list. This will remove an element at the specified index.

  6. How to remove an element from a nested list? - Stack Overflow

    Jun 16, 2010 · m=[[34,345,232],[23,343,342]] if I write m.remove(345) it gives an error message saying the element is not in the list. I want to know how to remove an element from ...

  7. python - 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 on a …

  8. Remove First occurance of an element from list python

    Oct 1, 2018 · Remove First occurance of an element from list python Asked 7 years, 4 months ago Modified 7 years, 4 months ago Viewed 2k times

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

    The effects of the three different methods to remove an element from a list: remove removes the first matching value, not a specific index:

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