三角:
冒泡排序:
numlist = [1,9,8,5,6,7,4,3,2] length = len(numlist) for i in range(length): for j in range(length-1-i): if numlist[j]>numlist[j+1]: # numlist[j],numlist[j+1]=numlist[j+1],numlist[j] numlist[j+1], numlist[j] = numlist[j], numlist[j+1] print(numlist)