L = [1,-2,3,7,-8,-9,10]
j=len(L)-1
i = 0
k = 0
while i<j:
while L[i]>0:
i=i+1
while L[j]<0:
j=j-1
if i<j:
k = L[i]
L[i]=L[j]
L[j] = k
print(L)
微信扫码预览、分享更方便