Discuss / Python / 困死啦,晚安~

困死啦,晚安~

Topic source

宋忠义_

#1 Created at ... [Delete] [Delete and Lock User]
def product(x, *num):
    if product is ():
        raise TypeError
    r = len(num)
    if r == 0:
        return x
    while r > 0:
        s = 1
        for n in num:
            s *= n
            r -= 1
        return s * x

#--------------------------------------

def product(*num):
    if len(num) != 0:
        x = 1
        for y in num:
            x *= y
        return x
    else:
        raise TypeError

#--------------------------------------

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

  • 1

Reply