给出的答案在python中复制黏贴报错?
>>> s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
>>> for name in L:
if name in s:
s.remove(name)
else:
s.add(name)
print s
SyntaxError: invalid syntax
>>> for name in L:
if name in s:
s.remove(name)
else:
s.add(name)
Traceback (most recent call last):
File "<pyshell#60>", line 1, in <module>
for name in L:
NameError: name 'L' is not defined