good, bad = [], []
for x in mylist:
(bad, good)[x in goodvals].append(x)
More Related Contents:
- I have a list of file names and I need to be able to count how many of the same file gets repeated for each file name [closed]
- How do I check if a list is empty?
- What does “list comprehension” and similar mean? How does it work and how can I use it?
- What’s the difference between lists and tuples?
- Dictionary: Get list of values for list of keys
- Flatten an irregular list of lists
- Python: Removing list element while iterating over list [duplicate]
- Converting a String to a List of Words?
- In Python, when to use a Dictionary, List or Set?
- How to perform element-wise multiplication of two lists?
- Check if something is (not) in a list in Python
- elegant find sub-list in list
- How to group a list of tuples/objects by similar index/attribute in python?
- How to force a list to a fixed size?
- What is the inverse function of zip in python? [duplicate]
- Pandas expand rows from list data available in column
- How to check if an object is a list or tuple (but not string)?
- How to remove all duplicate items from a list [duplicate]
- Unpack list to variables
- Python using enumerate inside list comprehension
- How to find common elements in list of lists?
- How to convert a string list into an integer in python [duplicate]
- Convert list of strings to dictionary
- Most efficient way for a lookup/search in a huge list (python)
- Sort list of strings by a part of the string
- How to make a completely unshared copy of a complicated list? (Deep copy is not enough)
- How can I partition (split up, divide) a list based on a condition?
- Python: Rename duplicates in list with progressive numbers without sorting list
- What is the cost/ complexity of insert in list at some location?
- Check list monotonicity