为什么结果显示runtimeerror set changed size during iteration python
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for name in s:
if name in L :
s.remove(name)
else:
s.add(name)
print s
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for name in s:
if name in L :
s.remove(name)
else:
s.add(name)
print s
2014-11-26
举报