Q:

How can I compare elements in 2 lists in the same index in their respective lists in Python? 

Say I have 2 lists
a = [1, 2, 3, 4, 7, 1]
b = [1, 2, 4, 5, 7, 1]

I want it to make a third list with only the elements that are equal in the same index in each list, in this case
c = [1, 2, 7, 1]

Is there a simple way to do this? 

A:

simplest method would probably just be doing a list comprehension:
c = [x for x,y in zip(a,b) if x == y]

for the sake of a different approach and just out of interest..could also do it this way:
from itertools import compress
mask = [x==y for x,y in zip(a,b)]
c = list(compress(a,mask))

or if numpy is an option (good for larger lists):
import numpy as np
a,b = np.array(a), np.array(b)
c = a[np.equal(a,b)].tolist()

all ways give: 
[1, 2, 7, 1]

