Python总体评价
问题描述:
我有一个列表(listA),我有另一个单独的列表(listB)。我正在尝试检查listB是否与listA中的任何列表匹配,基于我在test12函数中完成的类型和位置。我的问题是我能做些什么来让if语句给我一个总体评估,即真或假。当有一个或多个匹配时为真,如果没有匹配则为假。Python总体评价
listA = [[3,"alpha"], [7, 8], ["hat", "bat"]]
listB = [5,5]
def testing12(x,y):
result = map(type, x) == map(type, y)
return result
for n in lists:
if testing12(list,n) == True:
print "True"
else:
print "False"
['任何()'](HTTPS://docs.python。 org/2/library/functions.html#any) – pzp
什么是'testing12(list,n)'中的'list'?如果是内建'list','map(type,list)'会引发错误。 – gil
testin12(list,n)中的对不起list意味着listB –