Discuss / Python / 作业

作业

Topic source

def product(*agrs):
if len(agrs) == 0 : #
raise TypeError('bad operand type') result = 1 for num in agrs: if not isinstance(n, (int, float)): # raise TypeError('bad operand type') result = result * num
return result

#只能一个*?

def product(*agrs): if len(agrs) == 0 : # raise TypeError('bad operand type') result = 1 for num in agrs: if not isinstance(num, (int, float)): # raise TypeError('bad operand type') result = result * num return result


  • 1

Reply