python列表中怎样加入重复的元素
发布网友
发布时间:2022-04-23 04:28
我来回答
共1个回答
热心网友
时间:2023-10-14 19:06
#!usr/bin/python
resList = [];
resList1 = [1,2,3,1,3]
resList2 = []
for i in range(len(resList1)):
if(resList1.count(resList1[i]) >=2 ):
if(resList2.count(resList1[i]) >= 1):
continue
else:
resList2.append(resList1[i])
print resList2