Python: return list of sequentially occuring common items from lists and also a list of uncommon ones
Question: 
    lists = [[a,b,c,d],[a,b,c,d,e],[a,b,c,x],[a,b,c,d,e,f]....lots]
    
    common_items = [a,b,c]
    uncommon_items = [[d], [d,e], [x], [d,e,f]]
    
    common_elements(lists[0],lists[1])
    
    def common_elements(list1, list2):
        return [element for element in list1 if element in list2]
    

lot of the answers on SO only able to do this with two lists at a time. need
one that can handle any number of lists, and returns two lists.

Note: Order of list is important which leaves out sets. Note: Must be lowest
common items from each list, not based on the just the first list in lists.


Answer: The easiest way is to use sets, but you will lose ordering.

    
    
    lists = [['a','b','c','d'],
             ['a','b','c','d','e'],
             ['a','b','c','x'],
             ['a','b','c','d','e','f']]
    
    sets = map(set, lists)
    common = set.intersection(*sets)
    uncommon = [s-common for s in sets]
    print common    # set(['a', 'c', 'b'])
    print uncommon  # [set(['d']), set(['e', 'd']), set(['x']), set(['e', 'd', 'f'])]
    

Sets are the best way to represent common elements. You can maintain the order
of uncommon elements by using a different lists comprehension.

    
    
    uncommon = [[x for x in l if x not in common] for l in lists]
    print uncommon  # [['d'], ['d', 'e'], ['x'], ['d', 'e', 'f']]
    

Assuming the elements of `common` appear in the same order in all lists, you
can then convert the common set to a list.

    
    
    common = [x for x in lists[0] if x in common]
    

