title: How to count the steps in a sorting took to sort the numbers in python?
body: <p>I have used this coding in bubble sort function for step calculation taken to do sorting</p>
  
  <pre><code> def bubble(self):
      def bubble_sort ( array ) :
          swap_test = False
          for i in range ( 0, len ( array ) - 1 ):
           for j in range ( 0, len ( array ) - i - 1 ):
            if array[j] &gt; array[j + 1] :
             array[j], array[j + 1] = array[j + 1], array[j]#elegentan way of swap
  
             swap_test = True
             self.textbox()
            else:
                 self.sortingend()
           break
             #if swap_test == False:
          #else:
          #self.create_label()
  
     #print('bubble to be implemented')
      bubble_sort(self.nums)
      return self.nums
  </code></pre>
  
  <p>and for the two functions sortingend () and textbox() i have used these two codes</p>
  
  <pre><code>def sortingend(self):
      self.label21 = Label(self, text="Sorting Finish", width=25, height=2)
      self.label21.grid(row=7, column=1, sticky=N)
  
  def textbox(self):
      count=0
      count +=1
      self.label1 = Label(self, text="Step: %i " % count, width=25, height=2)
      self.label1.grid(row=6, column=1, sticky=N)
  </code></pre>
  
  <p>but somehow this is not working and i am only getting error for count+=1 that not defined but if i put count=o in sortingend() then everytime counter will start from o.
  Also when i run bubble sort on the first step only its showing that sorting finfished. how to correct this.</p>