reduce()
is called with 2 arguments always, so your u
argument is set to the second value in y
, a tuple. The default is ignored.
You really shouldn't use reduce()
here. reduce()
you need when you want to use the next element in the iterator for each loop iteration to calculate one aggregate value.
You are mapping instead:
map(''.join, y)
or use a list comprehension:
[''.join(x) for x in y]