I wrote a piece python code like this
import random
val_hist = []
for i in range(100):
val_hist.append(random.randint(0,1000))
def print__(x):
print type(x[1])
map(lambda x: print__(x), list(enumerate(val_hist)))
l_tmp = list(enumerate(val_hist))
idx_list = map(lambda x: x[0], l_tmp)
val_list = map(lambda x: x[1], l_tmp)
print idx_list
print val_list
reduce(lambda sum, x: sum + x[1], list(enumerate(val_hist)))
print reduce(lambda sum, x: sum + x, val_hist)
print reduce(lambda sum, x: sum + x[1], list(enumerate(val_hist)))
When I ran this code, I got this error "TypeError: can only concatenate tuple (not "int") to tuple". Does anyone know how this happened? Or does anyone know how python function reduce works exactly?