- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Ways to concatenate tuples in Python
When it is required to concatenate multiple tuples, the '+' operator can be used. A tuple is an immutable data type. It means, values once defined can't be changed by accessing their index elements. If we try to change the elements, it results in an error. They are important contains since they ensure read-only access.
The '+' operator can be used to add numeric values or concatenate strings.
Below is a demonstration of the same −
my_tuple_1 = (11, 14, 0, 78, 33, 11) my_tuple_2 = (10, 78, 0, 56, 8, 34) print("The first tuple is : ") print(my_tuple_1) print("The second tuple is : ") print(my_tuple_2) my_result = my_tuple_1 + my_tuple_2 print("The tuple after concatenation is : " ) print(my_result)
The first tuple is : (11, 14, 0, 78, 33, 11) The second tuple is : (10, 78, 0, 56, 8, 34) The tuple after concatenation is : (11, 14, 0, 78, 33, 11, 10, 78, 0, 56, 8, 34)
- Two tuples are defined and are displayed on the console.
- They are concatenated using the '+' operator.
- This is assigned to a value.
- It is displayed on the console.
- How to Concatenate tuples to nested tuples in Python
- Different ways to concatenate Strings in Java
- Program to find number of ways we can concatenate words to make palindromes in Python
- In how many ways we can concatenate Strings in Java?
- How to split Python tuples into sub-tuples?
- Combining tuples in list of tuples in Python
- Chunk Tuples to N in Python
- Count tuples occurrence in list of tuples in Python
- Python program to find Tuples with positive elements in List of tuples
- Updating Tuples in Python
- Compare tuples in Python
- Remove duplicate tuples from list of tuples in Python
- How to concatenate two strings in Python?
- Flatten Tuples List to String in Python
- Python program to find Tuples with positive elements in a List of tuples