I have two lists that I would like to combine, but instead of increasing the number of items in the list, I'd actually like to join the items that have a matching index. For example:
List1 = ['A', 'B', 'C']
List2 = ['1', '2', '3']
List3 = ['A1', 'B2', 'C3']
I've seen quite a few other questions about simply combining two lists, but I'm afraid I haven't found anything that would achieve.
Any help would be much appreciated. Cheers.
>>> List1 = ['A', 'B', 'C']
>>> List2 = ['1', '2', '3']
>>> [x + y for x, y in zip(List1, List2)]
['A1', 'B2', 'C3']
>>> List1 = ['A', 'B', 'C']
>>> List2 = ['1', '2', '3']
>>> map(lambda a, b: a + b, List1, List2)
['A1', 'B2', 'C3']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With