Optimising list comparison

David Eppstein eppstein at ics.uci.edu
Fri Mar 15 19:10:32 EST 2002


How about simplifying the logic a bit:

    def compare():
        for i in range(len(list1)):
            if list1[i] + list2[i] == 1:
               return 0
        return 1

-- 
David Eppstein       UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/



More information about the Python-list mailing list