Discuss / Python / 玥儿

玥儿

Topic source

#1 Created at ... [Delete] [Delete and Lock User]
def mult(*x):

    if len(x) == 0:
        raise TypeError('至少传一个参数')
    sum = 1
    for n in x:
        if not isinstance(x,(int,float)):
          raise TypeError('bad operand type')
        else:
          sum = sum * n
        
    return sum

#2 Created at ... [Delete] [Delete and Lock User]
def mult(*x):
    if len(x) == 0:
       raise TypeError('至少传一个参数')
    sum = 1
    for n in x:
        if not isinstance(n,(int,float)):
           raise TypeError('bad operand type')
        else:
          sum = sum * n
        
    return sum

  • 1

Reply