fork download
  1. def push(a,stack):
  2. stack=[a]+stack
  3. return stack
  4.  
  5. def reverse(arr):
  6. res=[]
  7. for a in arr:
  8. res=push(a,res)
  9. return res
  10.  
  11. x=[1,2,3,4,5]
  12. rx=reverse(x)
  13. print(str(rx))
  14.  
  15.  
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
[5, 4, 3, 2, 1]