What is a good pythonic way to generate an array of results from multiple function calls with a function that changes what it returns after each call? For example, say I have a function foo
that returns 'callno-X'
each time it is called, and X is increased by 1 every time. I want to then be able to say something like bar(5)
that will call foo()
five times and gather the results in an array, returning ['callno-1','callno-2','callno-3','callno-4','callno-5']
. Is there any good way to do this?
问问题
59 次