python相乘
def product(*x, y=(1,)):#测试product((1,),(1,)),tuple或list不能相乘,怎么解决type(x)的类型为int,而不为tuple# result = 1# if type(x)==list or type(x)==tuple:# for num in x:# result = result * num# else:# result = result * x # if type(y)==list or type(y)==tuple:# for num in y:# result = result * num# else:# result = result * y# return result
python相乘
def product(*x, y=(1,)):#测试product((1,),(1,)),tuple或list不能相乘,怎么解决type(x)的类型为int,而不为tuple# result = 1# if type(x)==list or type(x)==tuple:# for num in x:# result = result * num# else:# result = result * x # if type(y)==list or type(y)==tuple:# for num in y:# result = result * num# else:# result = result * y# return result