Question: I have two arrays 

```
a = [ab,bc,cd]
b = [bc,ab,cd]

```

I want to compare each element of a with each element of b and then increase `counter += 1` if they match, else `counter -1` and display `counter` 

```
counter=0
for i in a:
 for j in b: 
   if a[i-1] == b[j-1]:
      counter = counter + 1
   elif a[i-1] != b[j-1]:
      counter = counter - 1
  print counter

```

I am getting weird results, I am new to programming and help is appreciated.

Sorry for copy paste error

Answer: 
Your `elif` condition is the same as your `if`, which is probably why it's not working for you. In fact, you don't even need a condition there; it should just be an `else` since you want to catch everything that didn't match the `if`. 

That said, this way is much nicer:

```
from itertools import product
counter = sum(1 if x==y else -1 for x, y in product(a, b))

```
```
a = ['ab','bc','cd']
b = ['bc','ab','cd']

counter = 0
for i in a:
    for j in b:
        if i == j:
            counter += 1
        else:
            counter -= 1
print counter

```