def bubblesort(list):
    index = len(mylist)
    n = index - 1
 
    for i in range(index - 1):
        for j in range(n):
            if mylist[j] > mylist[j+1]:
                mylist[j], mylist[j+1] = mylist[j+1], mylist[j]
                File.write(str(mylist) + "\n")
        n = n - 1
 
File = open("log.txt", 'w')
     
mylist = [3,1,9,5,3,7,2]
bubblesort(mylist)
 
File.close()
