Answer the question
In order to leave comments, you need to log in
How to generate an array of functions?
How to simplify code like this:
mas = []
for i in range(10):
def f(i):
mas.append(lambda: print(i))
f(i)
Answer the question
In order to leave comments, you need to log in
not quite, apparently, the example conveys the essence of what needs to be done,
maybe like this
mas = []
for i in range(10):
mas.append(i)
mas = []
def f(i):
mas.append(i)
for i in range(10):
f(i)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question