# this function receives a list, a function, and possibly additional parameters # and calls the function on the list with the parameters # the number of parameters is unknown in advance since they depend on func # * is used for packing an unpacking the arguments into / from a tuple # see here for documentation: # https://docs.python.org/3.4/tutorial/controlflow.html#arbitrary-argument-lists def info(lst,func,*params): return func(lst,*params) # calling examples # no additional parameters info([10,12,14,13,11],lambda l: sum([e for e in l if e>12])) info([10,12,14,13,11],lambda l: [e for e in l if e>12]) # one additional parameter info([10,12,14,13,11],lambda l,i: sorted(l)[i-1],2) # two additional parameters # note the "x if cond else y" syntax (this is an expression, not a statement) info([10,12,14,13,11],lambda l,i,j: l[i] if j