fork(1) download
  1. def outer(n):
  2. res = []
  3. for i in range(n):
  4. def closure(x):
  5. def inner():
  6. return x
  7. return inner
  8. res.append(closure(i))
  9. return res
  10.  
  11. for f in outer(3):
  12. print(f())
Success #stdin #stdout 0.04s 9600KB
stdin
Standard input is empty
stdout
0
1
2