lambda function as a list number : List Element « List « Python






lambda function as a list number

lambda function as a list number

L = [(lambda x: x**2), (lambda x: x**3), (lambda x: x**4)]

for f in L:
    print f(2)     # prints 4, 8, 16

print L[0](3)      # prints 9

           
       








Related examples in the same category

1.Class inside a ListClass inside a List
2.Int, string, function, and list as list elementInt, string, function, and list as list element
3.List items need not all have the same type.List items need not all have the same type.