Python 如何修复列表中的两次追加
我在python上做了一个排序函数,但是它写了两次“2”,我怎么能修复它呢Python 如何修复列表中的两次追加,python,list,Python,List,我在python上做了一个排序函数,但是它写了两次“2”,我怎么能修复它呢 liste = [10,200,5,2,3] minimal = [] w = 0 try: sayac = 0 lent= (len(liste)-1) while True: sayac += 1 if lent == sayac: break else: listelen = (len(lis
liste = [10,200,5,2,3]
minimal = []
w = 0
try:
sayac = 0
lent= (len(liste)-1)
while True:
sayac += 1
if lent == sayac:
break
else:
listelen = (len(liste)-1)
for i in liste:
if i <= liste[w] and i <= liste[listelen] and i <= liste[int(listelen/2)]:
minimal.append(i)
else:
pass
print(minimal)
lent = (len(minimal)-1)
for i in liste:
if i == minimal[lent]:
liste.remove(i)
else:
pass
except:
print(minimal)
我的“liste”值上有一个1 2,但它写了两次我如何修复它?我的大脑现在消失了,因为您在第一步中添加了多个
最小值
,但随后仅从列表中删除最后一个:
liste=[10200,5,2,3]
最小值=[]
w=0
尝试:
sayac=0
lent=(len(liste)-1)
尽管如此:
sayac+=1
如果lent==sayac:
打破
其他:
listen=(len(liste)-1)
对于列表中的我:
如果我
OUT : [2, 3, 2, 5, 10, 200]
[2, 3, 2, 5, 10, 200]
...