Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. MyList = [83, 8, 44, 6, 28, 71, 41, 91, 9, 23]
  2. MaxIndex = len(MyList) - 1 # 9 here
  3. n = MaxIndex
  4. for i in range(0, MaxIndex): # Pass number
  5. for j in range(n): # all the way to 8, because range(9) goes to 8
  6. if MyList[j] > MyList[j + 1]:
  7. Temp = MyList[j]
  8. MyList[j] = MyList[j + 1]
  9. MyList[j + 1] = Temp
  10. n = n - 1
  11. print("Pass Number: ", i + 1, "; MyList: ", MyList) # human counting
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement