lst = [('NOUN', 'chip'), ('NOUN', 'potato'), ('potato', 'chip')]
permute_lst = [('NOUN', 'chip'), ('potato', 'chip'), ('potato', 'bbq'), ('NOUN', 'potato'), ('potato', 'crisp')]
我想在自定义函数中比较这两个元组列表以返回布尔值列表。我目前的代码:
def get_tf(lst):
tf_list = []
for lookup in permute_lst:
if set(lst) == set(lookup):
tf_list.append(True)
else:
tf_list.append(False)
return tf_list
结果 tf_list=[False, False, False, False, False]
我的预期结果是这样的:
tf_list = [True, True, False, True, False]
慕容森
相关分类