a= [9,1,5,3,7,2,8,6,4]
for i in range(len(a)):
    for j in range(len(a)-i-1):
        if a[j] > a[j+1]:
            a[j], a[j+1] = a[j+1], a[j]
            print(i+1, "회차", a)

print("최종 결과:", a)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: