Discuss / Python / 交作业

交作业

Topic source

杨森-ys

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

第一题:

def normalize(name):

    return name.title()#用了title函数

第二题:

def prod(L):

    l=1

    for n in L:

     l=l*n

    return l

    reduce(prod,L)

杨森-ys

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

第一题:

def normalize(name):

    return name[:1].upper()+name[1:].lower()

第二题:

def prod(L):

    def f(x,y):

        return x*y

    return reduce(f,L)


  • 1

Reply