Home ยป Concatenating two Tuples in python

Concatenating two Tuples in python

Java SE 11 Programmer I [1Z0-815] Practice Tests
Oracle Java Certification
Spring Framework Basics Video Course
Java SE 11 Developer (Upgrade) [1Z0-817]
Java SE 11 Programmer II [1Z0-816] Practice Tests
1 Year Subscription

We can add two tuples using the + operator.

The resultant tuple will have items from both the tuples.

Example

tuple1 = (1, 2, 3, 4, 5, 6)
tuple2 = (3, 4, 5, 6, 7, 8)

# concatenate tuples using the + operator
tuple3 = tuple1 + tuple2
print(tuple3)

When you run this you will see something like this

>>> %Run concatenatetuple.py
(1, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 8)

You may also like

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More