It’s normal to feel worried and tense the day before a programming contest. To relax, you went out fora drink with some friends in a nearby pub. To keep your mind sharp for the next day, you decided toplay the following game. To start, your friends w
方法一: a=[1,2,3] b=[1,3,4] c=list(set(a).intersection(set(b))) print c #[1,3] 这种方法是先把list转换为set,再用set求交集的方法完成list求交集. set是一个无序不重复元素集,基本功能包括关系测试.消除重复元素.集合对象还支持并.交.差.对称差等. set支持x in set, len(set) 和 for x in set.作为一个无序的集合,set不记录元素位置或插入点,因此,set不支持indexing,