Discuss / Python / 练习

练习

Topic source

首字母大写

from functools import reduce

def normalize(name):
    name=name.lower()
    name=name[0].upper()+name[1:]
    return name

L1 = ['adam', 'LISA', 'barT']
L2 = list(map(normalize, L1))
print(L2)

用reduce求积:

    def mul(x,y):
        return x*y
    return reduce(mul,L)

  • 1

Reply