fork download
  1. a = [7, 5, 3, 4, 8, 8, 9, 7, 6, 2]
  2. c = 0
  3.  
  4. for i in range(1, len(a)):
  5. if a[i-1] < a[i]:
  6. a[i-1], a[i] = a[i], a[i-1]
  7. else:
  8. c += 1
  9.  
  10. print(*a)
  11. print(c)
Success #stdin #stdout 0.04s 9596KB
stdin
Standard input is empty
stdout
7 5 4 8 8 9 7 6 3 2
3