def f7(L, e): e_lower = e.lower() e_len = len(e) L[:] = [x for x in L if len(x) != e_len or x.lower() != e_lower]
at my silly test datasets it works about twice faster not raising ValueError cause that ain't my point also note that replacing the function's L as in f4 and f5 won't affect the L of outside
Comment
if you're looking for speed, here's another one:
def f7(L, e):
e_lower = e.lower()
e_len = len(e)
L[:] = [x for x in L if len(x) != e_len or x.lower() != e_lower]
at my silly test datasets it works about twice faster
not raising ValueError cause that ain't my point
also note that replacing the function's L as in f4 and f5 won't affect the L of outside