How does concatenation operator work on tuple in Python?

PythonServer Side ProgrammingProgramming

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']
raja
Published on 05-Jan-2018 17:22:33
Advertisements