# -*- coding: utf-8 -*- def normalize(name): return name[0].upper() + name[1:].lower()
# -*- coding: utf-8 -*- from functools import reduce def prod(L): result = reduce(lambda x,y: x*y, L) return result
# -*- coding: utf-8 -*- from functools import reduce DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} def str2float(s): temp = s.split('.') s_L = temp[0] s_R = temp[1] def fn(x, y): return x * 10 + y def char2num(s): return DIGITS[s] x1 = reduce(fn,map(char2num,s_L)) x2 = reduce(fn,map(char2num,s_R))/(10**len(s_R)) return x1 + x2
Sign in to make a reply
Zflyee