Discuss / Python / 第二题:use reduce() function achieve the function of product

第二题:use reduce() function achieve the function of product

Topic source
def prod(L):    return reduce(lambda x, y: x*y, L)print('3 * 5 * 7 * 9 =', prod([3, 5, 7, 9]))if prod([3, 5, 7, 9]) == 945:    print('测试成功!')else:    print('测试失败!')

  • 1

Reply