first: def normalize(name): return name[0].upper() + name[1:].lower()
L1 = ['adam', 'LISA', 'barT'] L2 = list(map(normalize, L1)) print(L2)
second: from functools import reduce def prod(L): def mul(x1,x2): return x1*x2 return reduce(mul,L)
print('3 5 7 * 9 =',prod([3,5,7,9]))
自己实在是太笨了,简单的题却花了很长的时间
Sign in to make a reply
叫我_小军
first: def normalize(name): return name[0].upper() + name[1:].lower()
L1 = ['adam', 'LISA', 'barT'] L2 = list(map(normalize, L1)) print(L2)
second: from functools import reduce def prod(L): def mul(x1,x2): return x1*x2 return reduce(mul,L)
print('3 5 7 * 9 =',prod([3,5,7,9]))
自己实在是太笨了,简单的题却花了很长的时间