def bubbleSort(randnums):
swpcount, compcount = 0, 0
for numbers in range(len(randnums)-1,0,-1):
for i in range(numbers):
compcount +=1
if randnums[i]>randnums[i+1]:
swpcount +=1
mash = randnums[i]
randnums[i] = randnums[i+1]
randnums[i+1] = mash
return swpcount, compcount
swpcount, compcount = bubbleSort(randnums)
当我运行该函数时,交换次数返回0。比较次数是正确的。如何返回正确的掉期数量?