fork download
  1. def reverse(lst):
  2. n = len(lst)
  3. for i in range(n//2):
  4. lst[i], lst[n-1-i] = lst[n-1-i], lst[i]
  5.  
  6. L = list(range(10))
  7. print(L)
  8. reverse(L)
  9. print(L)
  10.  
Success #stdin #stdout 0.03s 5852KB
stdin
Standard input is empty
stdout
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]