求助为何答案说是错的
s = set(['Adam', 'Lisa', 'Paul']) L = ['Adam', 'Lisa', 'Bart', 'Paul'] for x in L: if x in s: L.remove(x) else: s.add(x) print s help.我这答案说是输出错误,是不是因为set是无序的,所以输出与答案有出入? 运行成功,输出错误 set(['Lisa', 'Paul', 'Adam', 'Bart'])
s = set(['Adam', 'Lisa', 'Paul']) L = ['Adam', 'Lisa', 'Bart', 'Paul'] for x in L: if x in s: L.remove(x) else: s.add(x) print s help.我这答案说是输出错误,是不是因为set是无序的,所以输出与答案有出入? 运行成功,输出错误 set(['Lisa', 'Paul', 'Adam', 'Bart'])
2017-11-13
举报