>>> L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> S = set([1, 3, 5, 7, 9])
>>> for item in L:
... if item in S:
... S.remove(item)
... else:
... S.add(item)
... print(S)
...
{10}
和if齐平就还在for循环里,不缩进就在for循环外了。