How to use function with lambda function in Python

1 Answer

0 votes
def calc(lst, callback):
    lst_result = list()
    for elements in lst:
        lst_result.append(callback(elements))
    return lst_result


lst = [1, 2, 3, 4]
 
lst_result = calc(lst, lambda n : n*2)
print(lst_result)



'''
run:

[2, 4, 6, 8]

'''

 



answered Jan 31, 2020 by avibootz

Related questions

...