Reputation: 91
Not sure if there are dupes since I don't see any in similar situations as mine. Apologise if there are dupes!
I have a list of tuples a = [(1,4,5), (3,1,2)]
and b = [(7,5,3), (2,6,8)]
. I'd like to append a to b to make a single list of tuples. Is that possible or do I have to go the long way of converting both into lists and appending them?
Thank you for you help!
Upvotes: 0
Views: 658
Reputation: 642
To extend a with b
a += b
This is just syntactic sugar for
a.extend(b)
if you wanted to keep both original lists intact you could assign to a new var
c = a + b
Upvotes: 1
Reputation: 9552
You can do so in either of the following ways:
b = b + a # using the concatenation operator
b.extend(a) # Using extend() method
Upvotes: 2