如何解决如何比较嵌套列表并在python3中将不匹配项追加到新列表?
I want to compare 2 nested list. compare index 1 of list 1 with list 2 index 1 and appedn list 1,list 2 to the new list. in python3
l1 = [['a','bat','c'],['a','doll','c']]
l2 = [['a','flowers','god','c']]
output = []
for i in l1:
for j in l2:
if i[1] != j[1]:
output.append(j)
break
print(output)
Expected Output:
[['a','c']
我想比较2个嵌套列表。将列表1的索引1与列表2索引1和pedn列表1,列表2与新列表进行比较。在python3
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。