Write a Python program to convert a list to a string. In this programming language, we can use the join method to join or convert the list to a string.
The built-in string join() method combines the list elements into a single string using a given separator.
strlist = ["Kiwi", "USA", "UK", "India", "Japan"] str1 = ' ' str1 = str1.join(strlist) print(str1)

Convert list to string using list comprehension
The list comprehension applies the str() function to every item in a list because the for loop accesses each item. This helps access individual items, convert integers to strings, and then perform other operations. Refer to a Python list comprehension.
strlist = ["Learn", "Programming", "From", "Tutorial", "Gateway"] str1 = ' '.join([str(word) for word in strlist]) print(str1)
Learn Programming From Tutorial Gateway
Convert list to string using join and map function
Here, the map() function applies the str() function to each item in a list. Next, the join() method converts a list of strings to a string. Refer to Python string join and Python map.
strlist = ["Learn", "From", "Tutorial", "Gateway"] str1 = ' '.join(map(str, strlist)) print(str1)
Learn From Tutorial Gateway
In this example, the for loop iterates the items and adds them to empty str.
def listToString(strlist):
str1 = ''
for word in strlist:
str1 = str1 + word + ' '
return str1
strlist = ["Py", "Programs", "From", "Tutorial", "Gateway"]
print(listToString(strlist))
Py Programs From Tutorial Gateway
In this Python example, we have shown all the possibilities for converting a list to a string.
def listToString(strlist):
str1 = ''
for word in strlist:
str1 = str1 + word + ' '
return str1
strlist = ["Learn", "Program", "From", "Tutorial", "Gateway"]
str1 = ' '
str1 = str1.join(strlist)
print("join method output = ", str1)
str2 = ' '.join([str(word) for word in strlist])
print("List Comprehension output = ", str2)
str3 = ' '.join(map(str, strlist))
print("map output = ", str3)
print("Custom Function output = ", listToString(strlist))
join method output = Learn Programs From Tutorial Gateway
List Comprehension output = Learn Programs From Tutorial Gateway
map output = Learn Programs From Tutorial Gateway
Custom Function output = Learn Programs From Tutorial Gateway
Also Read