"tonyon boyo" <[email protected]> wrote
i know how to print for bubble sort in python, is there a way to print each pass in the sort so i can see what happens at each step? thanks

Yes add a print statement inside the looop that prints the list being sorted.

def bubblesort(list):
     for passes in range(len(list)-1, 0, -1):

You could use list slicing here:

      for passes in list[-2::-1]:

But you might find using a while loop is easier than a for loop
for bubble sort

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to