There are some basic error in that loop.
What happens when you assassin variables in a loop?
set is maybe the bests way or iterate over and compare.
What happens when you assassin variables in a loop?
for i in range(5): start = i end = iSo if test:
>>> start 4 >>> end 4There are several way to compare list(
cmp
don't use it,cmp is removed in Python 3).set is maybe the bests way or iterate over and compare.
# Iterate with list comprehension >>> a = [1, 2, 3, 4, 5] >>> b = [9, 8, 7, 6, 5] >>> [x for x in a if x in b] [5] >>> [x for x in a if x not in b] [1, 2, 3, 4] >>> # set >>> set(a) & set(b) {5} >>> set(a) - set(b) {1, 2, 3, 4}