Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Split a list based on a condition

good, bad = [], []
for x in mylist:
    (bad, good)[x in goodvals].append(x)
    
# good.append(x) if x in goodvals else bad.append(x)
# for x in mylist: (good if isgood(x) else bad).append(x)
# (good if x in goodvals else bad).append(x)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Split #list #based #condition
ADD COMMENT
Topic
Name
9+1 =