请问“else”那里缩进与不缩进有什么区别?
>>> 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}
>>> 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}
2020-09-26
举报