3

I've searched around and it seems like nobody has asked this question (or at least I can't find it).

I have two lists of tuples and I want to join them to one list of tuples.

first = [('a', 1), ('b',2)]
second = [('c',3), ('d',4)]

I have tried appending, joining, zipping, but none of those are quite right. I want to get this:

wanted = [('a', 1), ('b',2), ('c',3), ('d',4)]

Is there a simple way to do this?

EDIT: I feel really stupid... of course its the one thing I forgot to try :(

SnarkShark
  • 360
  • 1
  • 7
  • 20

1 Answers1

8

You can use +

>>> first = [('a', 1), ('b',2)]
>>> second = [('c',3), ('d',4)]
>>> first + second
[('a', 1), ('b', 2), ('c', 3), ('d', 4)]
Chaker
  • 1,197
  • 9
  • 22