Created
September 9, 2020 21:14
-
-
Save tamert/7452aca576a23790ef4b17ee76815df5 to your computer and use it in GitHub Desktop.
6_reduce.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce | |
liste = [1,2,3,4,5] | |
def carp(mevcut, siradaki): | |
return mevcut*siradaki | |
print(reduce(carp, liste)) | |
#out: 120 | |
# yada lambda terimi ile kullanalım | |
print(reduce(lambda mevcut, siradaki: mevcut*siradaki, liste)) | |
# out: 120 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment