Advertisement
syvshc

Untitled

Aug 8th, 2022
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. def fcount():
  2.   fs = []
  3.   for i in range (1, 3):
  4.     def f():
  5.       return i
  6.     fs.append(f)
  7.   return fs
  8. f1, f2 = fcount()
  9. print(f1(), f2())
  10. # return 2, 2
  11.  
  12. def gcount():
  13.   gs = []
  14.   def g():
  15.     return 1
  16.   gs.append(g)
  17.   def g():
  18.     return 2
  19.   gs.append(g)
  20.   return gs
  21. g1, g2 = gcount()
  22. print(g1(), g2())
  23. # return 1, 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement