Pythonic way to compare two lists and print out the differences

前端 未结 7 1727
滥情空心
滥情空心 2021-02-07 10:52

I have two lists which are guaranteed to be the same length. I want to compare the corresponding values in the list (except the first item) and print out the ones which dont mat

相关标签:
7条回答
  • 2021-02-07 11:31

    edit: oops, didn't see the "ignore first item" part

    from itertools import islice,izip
    
    for a,b in islice(izip(list1,list2),1,None):
        if a != b:
           print a, b
    
    0 讨论(0)
提交回复
热议问题