- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
# 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.
['A B C', 'Tutorialspoint is a popular site for tech learnings']
If you have any queries in the article, mention them in the comment section.
- Python – Concatenate Rear elements in Tuple List
- Count occurrence of all elements of list in a tuple in Python
- Delete Tuple Elements in Python
- Matplotlib – Make a Frequency histogram from a list with tuple elements in Python
- Flatten tuple of List to tuple in Python
- Convert a list into a tuple in Python.
- Python program to count the elements in a list until an element is a Tuple?
- Modulo of tuple elements in Python
- How to join list of lists in python?
- How to append elements in Python tuple?
- Convert a list into tuple of lists in Python
- Create a tuple from string and list in Python
- How to convert a list into a tuple in Python?
- Maximum element in tuple list in Python
- Raise elements of tuple as power to another tuple in Python