# 比较 3 个不同列表的位置和元素Compare position and elements of 3 different lists

``````a = [FF2, FF6, FC4]
b = [FB5, FB3, FC4]
c = [FF2, FB3, FM8]

Result = [FF2, FB3, FC4]
``````

``````for i, v in enumerate(a):
for i1, v1 in enumerate(b):
if (i==i1) & (v==v1):
Result.append(v)
``````

``````Result = list(x for x, (xa, xb, xc) in enumerate(zip(a, b, c))
if xa == xb or xb == xc or xa == xc)
``````

## 3 个回复3

### #1楼 票数：2

``````a = ['FF2', 'FF6', 'FC4']
b = ['FB5', 'FB3', 'FC4']
c = ['FF2', 'FB3', 'FM8']

r = [x for t in zip(a, b, c) for x in set(t) if t.count(x) > 1]
``````

``````>>> r
['FF2', 'FB3', 'FC4']
``````

### #2楼 票数：2 已采纳

``````al = ['FF2', 'FF6', 'FC4']
bl = ['FB5', 'FB3', 'FC4']
cl = ['FF2', 'FB3', 'FM8']

res = []
for a,b,c in zip(al, bl, cl):
if a == b or b == c or c == a:
if a == b:
res.append(a)
elif b == c:
res.append(b)
elif c == a:
res.append(c)

print(res)
``````

### #3楼 票数：1

``````a = ["FF2", "FF6", "FC4"]
b = ["FB5", "FB3", "FC4"]
c = ["FF2", "FB3", "FM8"]

result = []
for idx in range(len(a)):
if a[idx] == b[idx] or a[idx] == c[idx]:
result.append(a[idx])
elif b[idx] == c[idx]:
result.append(b[idx])
else:
pass

print(result)
``````

``````['FF2', 'FB3', 'FC4']
``````

6回复

3回复

2回复

1回复

3回复

3回复

1回复

3回复