【发布时间】:2019-01-29 17:43:06
【问题描述】:
我有两个保证长度相同的列表。我想比较列表中的相应值(第一项除外)并打印出不匹配的值。我的做法是这样的
i = len(list1)
if i == 1:
print 'Nothing to compare'
else:
for i in range(i):
if not (i == 0):
if list1[i] != list2[i]:
print list1[i]
print list2[i]
有没有更好的方法来做到这一点? (Python 2.x)
【问题讨论】:
-
函数式编程的救援:查看地图和压缩包!
标签: python comparison