Python 计算列表元素之积
Python 计算列表元素之积的例子
定义一个数字列表,并计算列表元素之积。
例如:
# Filename : example.py
# DateTime : 2020-07-20
# author by : www.lidihuo.com
def multiplyList(myList) :
result = 1
for x in myList:
result = result * x
return result
list1 = [1, 2, 3]
list2 = [3, 2, 4]
print(multiplyList(list1))
print(multiplyList(list2))
以上实例输出结果为: