标签:cti amp for lambda reduce too res factor col
from functools import reduce i = int(input("input a number 1-10: ")) result = reduce(lambda a, b: a*b, [item for item in range(1,i+1)]) print(f‘factorial of {i+1} is {result}‘)
运行结果
input a number 1-10: 5 factorial of 6 is 120
[Python]reduce function & lambda function & factorial
标签:cti amp for lambda reduce too res factor col
原文地址:https://www.cnblogs.com/profesor/p/13056394.html