返回顶部

收藏

Do a map on list

更多
counters = [1, 2, 3, 4]

updated = []
for x in counters:
     updated.append(x + 10)              # add 10 to each item

print updated

def inc(x): return x + 10               # function to be run

print map(inc, counters)                      # collect results

print map((lambda x: x + 3), counters)        # function expression

标签:Python,Buildin,Function

收藏

0人收藏

支持

0

反对

0