A=['a','b','c']
b=['c','d','e']
cont = False
for i in A:
if i in B:
cont = True
break
print cont
如果解决了您的问题请采纳!
如果未解决请继续追问
# 以下使用 py3 set
# 交集
A=['a','b','c']
B=['c','d','e']
# 两个集合中的相同元素
res = list(set(A).intersection(set(B)))
# 判断b里面的元素有一个在A里
boo = len(res) > 0
将A和b都转成set集合,然后用集合作差,也就是作交集运算, 如果得到结果不为空,就表示b里面有一个元素在A里面也存在
A=['a','b','c']
b=['c','d','e']
cont = False
for i in A:
if i in B:
cont = True
break
print cont