In python 3, I have a function that returns a list of variable size
I would like to run this function over a list and concatenate the results. for example::
def the_func(x):
return [x]*x
def mapvar(f,v):
ans=[]
for x in v:
ans.extend(f(x))
return ans
print (mapvar(the_func,range(10)))
Is there a best practice in python to do this? if is there a standard mapvar function?