首字母大写
###字母首写大写
L1 = ['AdmIn','anny','LUCY','sandY','wILl'] def normallize(name): return name.capitalize() L2=map(normallize,L1) # L2 = list(map(normallize,L1)) print(type(L2))
运行结果:['Admin', 'Anny', 'Lucy', 'Sandy', 'Will']
L1 = ['AdmIn','anny','LUCY','sandY','wILl'] L2=[] for i in L1: L2.append(i.capitalize()) print(L2)
def square(x) : # 计算平方数 return x ** 2 print(map(square,[2,3,4,5])) print(list(map(square,[2,3,4,5])))