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,
If you just have a set amount of elements to join you can use str.format:
print(list(map(lambda x: "{}{}".format(*x) , v)))
['a1', 'a2', 'a3', 'a4', 'b1', 'b2', 'b3', 'b4', 'c1', 'c2', 'c3', 'c4']
You can also do it for any amount of elements using "{}" * len(x)
:
print(list(map(lambda x: ("{}" * len(x)).format(*x) , v)))
*x
unpacks the sequence, "{}" * len(x)
creates a {}
for each element in each sublist.
Or unpack in a list comp:
print([ "{}{}".format(*x) for x in v])