I would like to write a program count the items that appear in BOTH list
[code=python]
A=['A', 'B', 'C','D', 'F','G', 'H']
B=['FF', 'GG', 'A','B', 'DD','EE', 'GG']
for i in range(len(A)):
count=0
for k in range(len(B)):
if A[i]==B[k]:
count+=1
count
[/code]
the result is 0 but it should be 2 (for 'A' and 'B')
What did I do wrong?
[code=python]
A=['A', 'B', 'C','D', 'F','G', 'H']
B=['FF', 'GG', 'A','B', 'DD','EE', 'GG']
for i in range(len(A)):
count=0
for k in range(len(B)):
if A[i]==B[k]:
count+=1
count
[/code]
the result is 0 but it should be 2 (for 'A' and 'B')
What did I do wrong?
Comment