I often avoid me to write posts like this but I\'m new in python 3.4 and I need a help with this code.
Suppose we have the following list:
v = [ [ x,
lambda (x, y): ''.join(x,y) isn't legal Python 3. Iterable unpacking of arguments was removed. If you actually ran the code you showed on the version you mentioned, you would have gotten a syntax error, not the error you showed.
If you did indeed have a list as you describe, not the one you actually made, you would need to give str.join one iterable argument, not 2 arguments, so lambda (x, y): ''.join([x,y]) (which is similar to the code you showed but not legal Python 3) or, more simply, lambda x_y: ''.join(x_y)
That won't work for you, though, because str.join takes an iterable of strings, and the resulting list of lists in your case is [ ['a', 1], ['a',2], ... ], not [ ['a', '1'], ['a','2'], ... ]. You can't join a string and a number this way. (Which is fine, since str.join isn't even the right tool for the job.)
Using map+lambda is always silly. Just use a generator expression in all situations you might use map+lambda
See the following examples (I used list comprehensions instead of generator expressions so we'd get useful reprs):
py> v = [ [ x, y ] for x in ['a','b','c'] for y in range(1,5) ]
py> [''.join([let, num]) for let, num in v]
Traceback (most recent call last):
File "", line 1, in
File "", line 1, in
TypeError: sequence item 1: expected str instance, int found
py> ['{}{}'.format(let, num) for let, num in v]
['a1', 'a2', 'a3', 'a4', 'b1', 'b2', 'b3', 'b4', 'c1', 'c2', 'c3', 'c4']