Discuss / Python / 交作业,map()

交作业,map()

Topic source

再回首-知

#1 Created at ... [Delete] [Delete and Lock User]

def f1(x): return x.lower()

def f2(x): return x[0].upper()+x[1:]

s=['adaM','TOM','LISA','MIcheaL']

q=map(f2,map(f1,s))

print(list(q))

呜呜,用了1800s终于调通了 开始的时候写成 def f2(x): for m in range(len(x)): return x[m-1][0].upper()+x[m-1][1:] 这里弄重复了 map就是一对多的呀


  • 1

Reply