Python基础-List找重复数

请从L=[1,10,20,50,20,20,1]中找出重复数。

 1 L=[1,10,20,50,20,20,1]
 2 L1=[]
 3 for i in L:
 4     if(L.count(i)>1):
 5         L1.append(i)
 6 L2=[]
 7 for i in L1:
 8     if i not in L2:
 9         L2.append(i)
10 print L2

 

posted @ 2018-03-07 11:52  Python不秋  阅读(1307)  评论(0编辑  收藏  举报