def product(x, *y):
for i in y:
x=x*i
return x
请问第一个product(5)为什么等于5呢,y=()不是0个参数等于0吗
问1:乘积式子中只有因式5,所以product(5)等于5
问2:
sorry,刚刚回复错了。感觉应该是当y()参数为空时,for循环语句直接就被跳过了,然后直接执行return x(x为5)
Sign in to make a reply
正当风花雪月时
def product(x, *y):
for i in y:
x=x*i
return x