0

I have a tuple:

Tuple = (1, 2, 3)

"to aply str.format in the Tuple" def str_sume(Tuple): return '{} + {} = {}'.format(*Tuple)

I have two lists: L1 = [1, 2, 5] L2 = [5, 6, 8]

"to sum L1 and L2" def Sum(L1, L2): return list(map(lambda x, y: x + y, L1, L2))

SUM = Sum(L1, L2)

table = zip(L1, L2, SUM)

"to create a list of various tuples in wich all them have the str.format" def TABLE(table): return list(map(lambda triplet: str_sum(triplet), table))

TABLE(table) [ ]

The output I was waiting was: [('1 + 5 = 6'), ('2 + 6 = 8'), ('5 + 8 = 13')]

I don't understand was the output was an empty list I will appreciate somebody explain me way and tell me how to proceed to solve the problem. Thanks

Inti
  • 69
  • 4
  • Your code produces exactly that, just without the strange single-item-parenthezation? – Andrey Tyukin Apr 15 '18 at 23:31
  • @AndreyTyukin Sorry I was very unclear there.. I'm assuming they're calling `TABLE(table)` multiple times. Or printing `list(table)` somewhere. Which would work fine in Python 2. – miradulo Apr 15 '18 at 23:44
  • Sorry Andrey, as you say it is not a 'table' only a list of tuples. I just called it TABLE. I have just discovered that I had to put: – Inti Apr 15 '18 at 23:55
  • table = list(zip(L1, L2, SUM)), instead only table = zip(L1, L2, SUM). Thanks – Inti Apr 15 '18 at 23:57

0 Answers0