Given List of elements, convert it to delimiter separated String.
Input : test_list = [7, “Gfg”, “best”, 9], delim = “*”
Output : 7*Gfg*best*9*
Explanation : All elements are concatenated with “*” as joiner.
Input : test_list = [7, “Gfg”, “best”, 9], delim = “#”
Output : 7#Gfg#best#9#
Explanation : All elements are concatenated with “#” as joiner.
Method #1 : Using loop + str()
This is one of the ways in which this task can be performed. In this, we run a loop to add delimiter at end of each element, after converting each element to string.
The original list is : [7, 'Gfg', 8, 'is', 'best', 9] The resultant string : 7*Gfg*8*is*best*9*
Method #2 : Using join() + str()
This is yet another way in which this task can be performed. In this we perform the task of joining each element by delim using join() and conversion to string is done using str().
The original list is : [7, 'Gfg', 8, 'is', 'best', 9] The resultant string : 7*Gfg*8*is*best*9
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Python - Convert Delimiter separated list to Number
- Python - Construct dictionary Key-Value pairs separated by delimiter
- Python - Sort words separated by Delimiter
- Python program to convert a list of strings with a delimiter to a list of tuple
- Python - Convert delimiter seperated Mixed String to valid List
- Python | Convert list of strings to space separated string
- Python | Pandas str.join() to join string/list elements with passed delimiter
- Python | Convert key-value pair comma separated string into dictionary
- Python | Split on last occurrence of delimiter
- Python | Ways to split strings using newline delimiter
- Python - Replace delimiter
- Python - Segregate elements by delimiter
- Python - Concatenate Tuple elements by delimiter
- Python program to input a comma separated string
- How to read a CSV file to a Dataframe with custom delimiter in Pandas?
- Python | Convert List of String List to String List
- Python - Custom Split Comma Separated Words
- Python | Convert list of string to list of list
- Python | Convert list of tuples to list of list
- Python | Convert a string representation of list into list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.