1# Python program to convert a list
2# to string using list comprehension
3
4s = ['I', 'want', 4, 'apples', 'and', 18, 'bananas']
5
6# using list comprehension
7listToStr = ' '.join([str(elem) for elem in s])
8
9print(listToStr)
1list_of_num = [1, 2, 3, 4, 5]
2# Covert list of integers to a string
3full_str = ' '.join([str(elem) for elem in list_of_num])
4print(full_str)
1List = ["ITEM1", "ITEM2", "ITEM3"]
2string_version = "".join(List)
3
4print(string_version)
5
1my_list = ["Hello", 8, "World"]
2string = " ".join(my_list)
3print(string)
4"""
5output
6Hello 8 World
7"""
1>>> mylist = ['spam', 'ham', 'eggs']
2>>> print ', '.join(mylist)
3spam, ham, eggs
4