Python code to return total count of no. of positions in which items are differing at same index
Question: A=[1,2,3,4,5,6,7,8,9] B=[1,2,3,7,4,6,5,8,9]

I have to compare these two lists and return the count of no. of location in
which items are differing using one line python code.

For example: the output should be 4 for given arrays because at index
(3,4,5,6) the items are differing.So, program should return 4.

My way of doing this is comparing each and every location using for loop:

    
    
    count=0
    for i in range(0,len(A)):
       if(A[i]==B[i]):
         continue
       else:
         count+=1
    print(count)
    

Please help me in writing one line python code for this.


Answer: 
    count = sum(a != b for a, b in zip(A, B))
    print(count)
    

or just `print sum(a != b for a, b in zip(A, B))`

you can check about [zip/lambda/map
here](https://bradmontgomery.net/blog/pythons-zip-map-and-lambda/), those
tools are very powerfull and important in python..

[Here](http://stackoverflow.com/questions/14050824/add-sum-of-values-of-two-
lists-into-new-list) you can also check others kind of ways to use those
tools.

Have fun!!

