Removing each element at the value in each key
Question: 
    sample_dict = {'i.year': ['1997', '1997'], 'i.month': ['March', 'April'], 'j.month': ['March', 'April'], 'j.year': ['1997', '2003']}
    

How do we compare each element in i.year and j.year, and if the elements are
equal to each other, than delete the element at that index in the value at
each key and than move on to the next element and continue the process. The
length of each value will always be the same. _With no use of imports_

So basically what I'm trying to say is this:

For the sake of this question compare just the elements in i.year and j.year:

    
    
    -> {'i.year': ['1997', '1997'], 'i.month': ['March', 'April'], 'j.month': ['March', 'April'], 'j.year': ['1997', '2003']}
    -> The first element in i.year is equal to the first element in j.year, so delete the first element in each value in every key.
    

We get:

    
    
    -> {'i.year': ['1997'], 'i.month': ['April'], 'j.month': ['April'], 'j.year': ['2003']}
    -> The element now in i.year and j.year is the same so we're done. Return that dictionary
    

Another example:

    
    
    -> {'i.year': ['1997', '1997', '2009'], 'i.month': ['March', 'April', 'June'], 'j.month': ['March', 'April', 'June'], 'j.year': ['1997', '2003', '2010']}
    -> The first element in i.year is equal to the first element in j.year, so delete the first element in each value in every key.
    

We get:

    
    
    -> {'i.year': ['1997', '2009'], 'i.month': ['April', 'June'], 'j.month': ['April', 'June'], 'j.year': ['2003', '2010']}
    -> Now the first element in i.year and j.year are different so we move to the next element which is '2009' and '2010'
    -> '2009' and '2010' are different so we move to the next element, since there's none we are done. Return that dictionary.
    

Last example:

    
    
    -> {'i.year': ['1996', '1997', '2010'], 'i.month': ['March', 'April', 'June'], 'j.month': ['March', 'April', 'June'], 'j.year': ['1997', '2003', '2010']}
    -> The first element in i.year is not equal to the first element in j.year, so we move on to the next element.
    -> '1997' does not equal to '2003' so we move on to the next element
    -> '2010' is equal to '2010' so we delete each element in every key at the index
    

We get:

    
    
    -> {'i.year': ['1996', '1997'], 'i.month': ['March', 'April'], 'j.month': ['March', 'April'], 'j.year': ['1997', '2003']}
    -> There are no more elements to move on to, so we are done, we return this dictionary.
    

I have this idea but cant turn it into python code:

For every element in i.month loop through every element in j.year, and if the
elements are not equal loop through the entire dictionary and remove the
element at that index.


Answer: You can first find the indexes where the elements in `i.year` and `j.year` are
different, and then iterate over dict and filter out items that are not at
those indexes:

    
    
    def solve(d, *keys):
        indexes = [i for i, x in enumerate(zip(*(d[k] for k in keys)))
                                                                    if len(set(x)) != 1]
        return {k:[v[x] for x in indexes] for k, v in d.items()}
    

**Demo:**

    
    
    >>> d = {'i.year': ['1997', '1997'], 'i.month': ['March', 'April'], 'j.month': ['March', 'April'], 'j.year': ['1997', '2003']}
    >>> solve(d, 'i.year', 'j.year')
    {'i.year': ['1997'], 'j.month': ['April'], 'i.month': ['April'], 'j.year': ['2003']}
    
    >>> d = {'i.year': ['1997', '1997', '2009'], 'i.month': ['March', 'April', 'June'], 'j.month': ['March', 'April', 'June'], 'j.year': ['1997', '2003', '2010']}
    >>> solve(d, 'i.year', 'j.year')
    {'i.year': ['1997', '2009'], 'j.month': ['April', 'June'], 'i.month': ['April', 'June'], 'j.year': ['2003', '2010']}
    
    >>> d = {'i.year': ['1996', '1997', '2010'], 'i.month': ['March', 'April', 'June'], 'j.month': ['March', 'April', 'June'], 'j.year': ['1997', '2003', '2010']}
    >>> solve(d, 'i.year', 'j.year')
    {'i.year': ['1996', '1997'], 'j.month': ['March', 'April'], 'i.month': ['March', 'April'], 'j.year': ['1997', '2003']}
    

