Mega Code Archive

 
Categories / Python / Buildin Function
 

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