#第一题 L = ['adam', 'LISA', 'barT'] def normalize(name): return name.title() L2 = list(map(normalize,L)) print(L2) #第二题 def prod(L): return reduce(lambda x, y : x * y, L) #第三题 def char2num(char): return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}[char] def str2float(str): L = str.split(sep = '.') return reduce(lambda x, y : x * 10 + y, map(char2num,L[0])) + reduce(lambda x, y : x / 10 + y , list(map(char2num,L[1]))[::-1]) / 10
['Adam', 'Lisa', 'Bart']
prod([3,5,7,9]) 945 str2float('123.456789') 123.456789
第三题跟你写的一模一样...23333
Sign in to make a reply
_梦有你而美_
['Adam', 'Lisa', 'Bart']