Python Forum
can itertools compact a list removing all of some value?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can itertools compact a list removing all of some value?
#5
my first thought was:
n = 0
for i in range(len(test)):
    if test[i] is not None:
        test[n] = test[i]
        n += 1
test[n:] = []
but i don't know how safe or fast that is.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
RE: can itertools compact a list removing all of some value? - by Skaperen - Aug-30-2019, 08:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  itertools and amazing speed Pedroski55 8 2,323 Nov-11-2022, 01:20 PM
Last Post: Gribouillis
  What happens to a <itertools.permutations object at 0x7fe3cc66af68> after it is read? Pedroski55 3 2,635 Nov-29-2020, 08:35 AM
Last Post: DeaD_EyE
  Removing element from list squall 6 3,273 Nov-22-2020, 09:34 PM
Last Post: jefsummers
  Making lists using itertools and eliminating duplicates. mike3891 2 2,382 Oct-26-2020, 05:39 PM
Last Post: bowlofred
  Removing items from list if containing a substring pythonnewbie138 2 2,322 Aug-27-2020, 10:20 PM
Last Post: pythonnewbie138
  Python3 itertools.groupby printing the key august 1 2,186 Aug-17-2020, 05:46 AM
Last Post: bowlofred
  removing dictionary element in list using (key, value) MelonMusk 3 2,408 Jun-13-2020, 02:37 PM
Last Post: buran
  Generate Cartesian Products with Itertools Incrementally CoderMan 2 1,959 Jun-04-2020, 04:51 PM
Last Post: CoderMan
  Help removing asterisk item in a nested list. bmcguire 3 2,742 Apr-06-2020, 02:35 PM
Last Post: snippsat
  itertools.zip_shortest() fo unequal iterators Skaperen 10 7,148 Dec-27-2019, 12:17 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020