
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python - Join tuple elements in a list
In this article, we are going to learn how to join tuple elements in a list. It's a straightforward thing using join and map methods. Follow the below steps to complete the task.
- Initialize list with tuples that contain strings.
- Write a function called join_tuple_string that takes a tuple as arguments and return a string.
- Join the tuples in the list using map(join_tuple_string, list) method.
- Convert the result to list.
- Print the result.
Example
# initializing the list with tuples string_tuples = [('A', 'B', 'C'), ('Tutorialspoint', 'is a', 'popular', 'site', 'for tech learnings')] # function that converts tuple to string def join_tuple_string(strings_tuple) -> str: return ' '.join(strings_tuple) # joining all the tuples result = map(join_tuple_string, string_tuples) # converting and printing the result print(list(result))
If you run the above code, then you will get the following result.
Output
['A B C', 'Tutorialspoint is a popular site for tech learnings']
Conclusion
If you have any queries in the article, mention them in the comment section.
- Related Articles
- Python – Concatenate Rear elements in Tuple List
- Count occurrence of all elements of list in a tuple in Python
- Matplotlib – Make a Frequency histogram from a list with tuple elements in Python
- Delete Tuple Elements in Python
- Python program to count the elements in a list until an element is a Tuple?
- Flatten tuple of List to tuple in Python
- Python Program to Replace Elements in a Tuple
- Modulo of tuple elements in Python
- Python – Cross Pairing in Tuple List
- Why python returns tuple in list instead of list in list?
- Maximum element in tuple list in Python
- How to join list of lists in python?
- Convert a list into tuple of lists in Python
- Create a tuple from string and list in Python
- How to append elements in Python tuple?

Advertisements