Advertisement
Guest User

Untitled

a guest
Jan 15th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. import random
  2.  
  3. li = [7,3,4,9,0,1,8,2,5,6]
  4.  
  5. for x in range(len(li) - 1):
  6.     if li[x] > li[x + 1]:
  7.         temp = li[x + 1]
  8.        
  9.         for y in range(x, -1, -1):
  10.             if li[y] <= temp:
  11.                 break
  12.             li[y + 1] = li[y]
  13.             li[y] = temp        # unindent 1 level to see the bug in action
  14.  
  15.     print(li)
  16.  
  17. input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement