How to count the common elements in the same places of two lists in Python

1 Answer

0 votes
lst1 = [1, 8, 3, 4, 0, 25, 6, 2, 7] 
lst2 = [7, 8, 8, 9, 0, 87, 19, 2, 4] 
 
total = sum(n1 == n2 for n1, n2 in zip(lst1, lst2)) 

print(total)
 
 
 
'''
run:
 
3
 
'''

 



answered Jan 23, 2020 by avibootz

Related questions

...