Discuss / Python / 作业2

作业2

Topic source

默_kk

#1 Created at ... [Delete] [Delete and Lock User]
在此插入代码

from functools import reduce

d = {} for i in range(10): d[str(i)] = i

print(d)

def str2int(s): return d[s] def prod(s): return reduce(lambda x, y: x y, map(str2int, s)) print('3 5 7 9 =',prod('3579'))


  • 1

Reply