Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何修复列表中的两次追加_Python_List - Fatal编程技术网

Python 如何修复列表中的两次追加

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

我在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(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]
...