fork download
  1. def accumulator(l, item):
  2. l.append(item)
  3. return l
  4.  
  5. def f():
  6. accum = []
  7. def closure(item):
  8. return accumulator(accum, item)
  9.  
  10. closure(5)
  11. closure(7)
  12. print(accum)
  13.  
  14. accum = []
  15. closure(8)
  16. print(accum)
  17.  
  18. f()
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
[5, 7]
[8]