我需要一些帮助来搜索两个不同数据的单个列表,如何做到这一点,如果这样,如果这两个数据将输出值,那么就找到了。
答案 0 :(得分:3)
您可以使用几个in
运算符:
def both_in_list(lst, a, b):
return a in lst and b in lst
答案 1 :(得分:2)
list1 = [1,2,3,4,5,6]
list2 = [6,7,8,9,10]
if (6 in list1) and (6 in list2):
print("The elements that you're looking for is there!")
else:
print("One of the lists does not that the element you're looking for!")
答案 2 :(得分:1)
使用了几个in
运算符来执行此操作。
list = [2,4,8,14,16]
if 2 in list and 4 in list
print("2 and 4 are found in this list.")
else:
print("These numbers are not found in this list.")