Discuss / Python / 函数的参数

函数的参数

Topic source

landingguymmm

#1 Created at ... [Delete] [Delete and Lock User]

def product(*y):       

    if not y:

        raise TypeError #当参数为空时,返回错误

    else:

        s = 1

        for i in y:

            s = s * i

    return s

def product(x,*y):    for i in y:        x = x * i    return x

  • 1

Reply