Chapter 15. Lambda functions
Instead of defining the function somewhere and calling it, we can use python's lambda functions, which are inline functions defined at the same place we use it.
They don't need to have a name, so they also called anonymous functions. We define a lambda function using the keyword lambda.
your_function_name = lambda inputs : output
Exercise
l = [2,4,7,3,14,19]
for i in l:
odd_lambda = lambda x : x % 2 != 0
print(odd_lambda(i))
<script.py> output:
False
False
True
True
False
True
'이전 글' 카테고리의 다른 글
How to Plan an MVP? 완벽이라는 허상과 작별하라 (0) | 2023.12.20 |
---|---|
42Seoul 온라인 테스트 또 통과한 후기 (2) | 2023.01.18 |
Python Training Day 12. List Comprehensions (0) | 2022.12.25 |
Python Training Day 10 & 11. Pandas Basics, Generators (0) | 2022.12.23 |
Python Training Day 9. Numpy Arrays (0) | 2022.12.20 |