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相乘
最新推荐文章于 2022-04-01 23:31:42 发布