Computer >> Computer tutorials >  >> Programming >> Python

How does concatenation operator work on tuple in Python?


The concatenation operator creates a new tuple in Python using the initial tuples in the order they were added in. This is not an inplace operation. 

example

tuple1 = [1, 2, 3]
tuple2 = ['a', 'b']
tuple3 = tuple1 + tuple2
print(tuple3)

Output

This will give the output −

[1, 2, 3, 'a', 'b']